Skip to content

Commit 9eac458

Browse files
committed
Add split by blank lines in input reader
1 parent f4640de commit 9eac458

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

shared/paul2708/input_reader.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
from typing import List
22

33

4+
def read_split_lines(day: str) -> List[List[str]]:
5+
total_groups = []
6+
group = []
7+
for line in read_lines(day):
8+
if not line.strip():
9+
total_groups.append(group)
10+
group = []
11+
continue
12+
13+
group.append(line)
14+
15+
total_groups.append(group)
16+
17+
return total_groups
18+
19+
420
def read_ints(day: str) -> List[int]:
521
file = open(f"../../../shared/paul2708/input/{day}.txt", "r")
622

@@ -13,6 +29,7 @@ def read_ints(day: str) -> List[int]:
1329
file.close()
1430
return ints
1531

32+
1633
def read_lines(day: str) -> List[str]:
1734
file = open(f"../../../shared/paul2708/input/{day}.txt", "r")
1835

0 commit comments

Comments
 (0)