From 0ef97e71485466e9982734f811a6fde4ebed1fca Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Fri, 17 Dec 2021 20:10:11 +0000 Subject: utils --- utils.py | 5 +++++ 1 file changed, 5 insertions(+) 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() -- cgit v1.2.3-54-g00ecf