advent_of_code/1/1_2.py
kleph ba86d90e98
Some checks failed
continuous-integration/drone/push Build is failing
lint (W1514)
2022-04-05 13:56:34 +02: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}')