advent_of_code/2021/1/1_2.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

23 lines
543 B
Python
Executable file

#!/usr/bin/env python
# 2021 - Advent Of Code 1 - part 2
count = 0
with open('input.txt', encoding="utf-8") 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}')