Skip to content

Commit 3bf8893

Browse files
committed
Add file reader for day 5
1 parent a0d9f95 commit 3bf8893

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

s5.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,34 @@
33
from collections import defaultdict
44
from common import *
55

6+
ORDER_SEPARATOR = '|'
7+
UPDATE_SEPARATOR = ','
8+
9+
10+
def get_print_instructions():
11+
ordering = defaultdict(list)
12+
updates = []
13+
14+
for line in get_lines(strip_newlines=True):
15+
if ORDER_SEPARATOR in line:
16+
before, after = map(int, line.split(ORDER_SEPARATOR))
17+
ordering[before].append(after)
18+
elif UPDATE_SEPARATOR in line:
19+
updates.append([int(x) for x in line.split(UPDATE_SEPARATOR)])
20+
21+
return ordering, updates
22+
623

724
def part1():
8-
print('Part 1:')
25+
ordering, updates = get_print_instructions()
26+
count = 0
27+
28+
for update in updates:
29+
# for each update
30+
# check that pages follow the rules
31+
pass
32+
33+
print('Part 1:', count)
934

1035

1136
def part2():

0 commit comments

Comments
 (0)