advent_of_code/2021/8/8.py
kleph 9598e8f526
All checks were successful
continuous-integration/drone/push Build is passing
archive AoC 2021
2022-11-30 02:08:02 +01:00

25 lines
513 B
Python
Executable file

#!/usr/bin/env python
# 2021 - Advent Of Code - 8
def parse_file(file):
outs = []
with open(file, encoding="utf-8") as f:
for line in f.readlines():
_, out = line.strip().split('| ')
outs.append(out)
return outs
# outputs = parse_file('input_example.txt')
outputs = parse_file('input.txt')
count = 0
for o in outputs:
words = o.split(' ')
for w in words:
length = len(w)
if length in (2, 3, 4, 7):
count += 1
print(f'{count}')