2021-12-08 15:04:02 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# 2021 - Advent Of Code - 8
|
|
|
|
|
|
|
|
def parse_file(file):
|
|
|
|
outs = []
|
2022-04-05 13:27:24 +02:00
|
|
|
with open(file, encoding="utf-8") as f:
|
2021-12-08 15:04:02 +01:00
|
|
|
for line in f.readlines():
|
2021-12-13 05:38:24 +01:00
|
|
|
_, out = line.strip().split('| ')
|
2021-12-08 15:04:02 +01:00
|
|
|
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)
|
2021-12-13 05:38:24 +01:00
|
|
|
if length in (2, 3, 4, 7):
|
2021-12-08 15:04:02 +01:00
|
|
|
count += 1
|
|
|
|
|
|
|
|
print(f'{count}')
|