lots of cleanup
This commit is contained in:
parent
7d0d3e504e
commit
0385cbd62e
26 changed files with 337 additions and 417 deletions
19
advent/common/input.py
Normal file
19
advent/common/input.py
Normal 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')
|
||||
Loading…
Add table
Add a link
Reference in a new issue