diff options
-rw-r--r-- | utils.py | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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() |