lots of cleanup

This commit is contained in:
Ruediger Ludwig 2022-12-10 19:30:10 +01:00
parent 7d0d3e504e
commit 0385cbd62e
26 changed files with 337 additions and 417 deletions

19
advent/common/input.py Normal file
View file

@ -0,0 +1,19 @@
from pathlib import Path, PurePath
from typing import Iterator, TypeVar
T = TypeVar('T')
def read_lines(day: int, file_name: str) -> Iterator[str]:
'''
Returns an iterator over the content of the mentioned file
All lines are striped of an eventual trailing '\n' their
'''
with open(
Path.cwd()
/ PurePath('advent/days/day{0:02}/data'.format(day))
/ PurePath(file_name),
'rt',
) as file:
while line := file.readline():
yield line.rstrip('\n')