Files
advent-of-code/2021/01/part2

26 lines
391 B
Plaintext
Raw Normal View History

2022-01-09 17:50:50 +00:00
#!/usr/bin/env python
last = -1
count = 0
with open('input') as f:
window = []
for line in f:
depth = int(line)
window.append(depth)
if len(window) < 3:
continue
if len(window) > 3:
window.pop(0)
cur = sum(window)
if last > 0 and last < cur:
count = count +1
last = cur
print(count)