summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index 00d0d60..8b688a6 100644
--- a/utils.py
+++ b/utils.py
@@ -4,6 +4,7 @@ from collections.abc import Iterable, Iterator
from dataclasses import dataclass
from itertools import islice
from math import sqrt
+from re import match as re_match
from sys import argv
from typing import TypeVar, Generic, Union, Optional, cast
@@ -73,3 +74,7 @@ def open_day(n: int):
if len(argv) == 2:
return open(argv[1])
return open(f'{n}.in')
+
+def parse_day(n: int, regex: str):
+ with open_day(n) as f:
+ return re_match(regex, f.read().rstrip()).groups()