Advent-of-Code/2021/8/main.py

30 lines
937 B
Python
Raw Normal View History

2021-12-08 13:50:24 -05:00
# 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)