advent_of_code/1/1_2.py
2021-12-06 01:34:42 +01:00

23 lines
525 B
Python
Executable file

#!/usr/bin/env python
# 2021 - Advent Of Code 1 - part 2
count = 0
with open('input.txt') as f:
n2_value = int(f.readline())
n1_value = int(f.readline())
n_value = int(f.readline())
previous_sum = n2_value + n1_value + n_value
for line in f:
n2_value = n1_value
n1_value = n_value
n_value = int(line)
current_sum = n2_value + n1_value + n_value
if current_sum > previous_sum:
count += 1
previous_sum = current_sum
print(f'count: {count}')