24 lines
525 B
Python
24 lines
525 B
Python
|
#!/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}')
|