26 lines
532 B
Python
26 lines
532 B
Python
|
#!/usr/bin/env python
|
||
|
# 2021 - Advent Of Code - 8
|
||
|
|
||
|
def parse_file(file):
|
||
|
outs = []
|
||
|
with open(file) as f:
|
||
|
for line in f.readlines():
|
||
|
nums, 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 == 2 or length == 3 or length == 4 or length == 7:
|
||
|
count += 1
|
||
|
|
||
|
print(f'{count}')
|