advent/2021/1/2.py

17 lines
370 B
Python
Raw Normal View History

2022-07-02 16:31:24 -05:00
#!/usr/bin/env python3
file = [int(i.rstrip()) for i in open("input").readlines()]
count = 0
for i in range(len(file)):
try:
firstwindowsum = file[i] + file[i + 1] + file[i + 2]
secondwindowsum = file[i + 1] + file[i + 2] + file[i + 3]
except IndexError:
break
if secondwindowsum > firstwindowsum:
count += 1
print(count)