diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-17 20:10:11 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-17 20:10:11 +0000 |
commit | 0ef97e71485466e9982734f811a6fde4ebed1fca (patch) | |
tree | 9a5a1dfa81dee4f48426d8254dae00c83ae1c0ec | |
parent | 522edc867cc2bc6993da73701b0c13a538621700 (diff) | |
download | aoc2021-0ef97e71485466e9982734f811a6fde4ebed1fca.tar.gz aoc2021-0ef97e71485466e9982734f811a6fde4ebed1fca.tar.xz aoc2021-0ef97e71485466e9982734f811a6fde4ebed1fca.zip |
utils
-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() |