Day 8 Part 1.

This commit is contained in:
David Vereb
2021-12-08 13:50:24 -05:00
parent 9c1dcaeece
commit da794f1967
3 changed files with 239 additions and 0 deletions

29
2021/8/main.py Normal file
View File

@@ -0,0 +1,29 @@
# 0: 1: 2: 3: 4:
# aaaa .... aaaa aaaa ....
# b c . c . c . c b c
# b c . c . c . c b c
# .... .... dddd dddd dddd
# e f . f e . . f . f
# e f . f e . . f . f
# gggg .... gggg gggg ....
# 5: 6: 7: 8: 9:
# aaaa aaaa aaaa aaaa aaaa
# b . b . . c b c b c
# b . b . . c b c b c
# dddd dddd .... dddd dddd
# . f e f . f e f . f
# . f e f . f e f . f
# gggg gggg .... gggg gggg
total = 0
with open('data', 'r') as fp:
# NOTE(dev): We assume all lines are the same length
for line in fp:
line = line.split(' | ')[1]
vals = line.split()
for val in vals:
if(len(val) in [2, 3, 4, 7]):
total += 1
print(total)