advent_of_code/2021/01/count_larger-01.py

20 lines
518 B
Python
Executable File

#!/usr/bin/python3
larger = 0
current = -1
with open('input.txt', 'r') as myfile:
for line in myfile:
if int(line.strip()) < current:
print('{} is smaller as {}'.format(line.strip(), current))
current = int(line.strip())
else:
print('{} is larger as {}'.format(line.strip(), current))
larger = larger + 1
current = int(line.strip())
print('{} measurements are larger than the previous measurement'.format(larger - 1))