aoc-2021/day_1/code2.py
2021-12-05 16:52:20 +01:00

18 lines
328 B
Python

import fileinput
data = []
for inp in fileinput.input():
val = inp.strip()
if val != '':
int_value = int(val)
data.append(int_value)
prec = None
count = 0
for i in range(len(data) - 2):
s = data[i]+data[i+1]+data[i+2]
if prec != None and s > prec:
count += 1
prec = s
print(count)