aoc2021/d01/d01_2.py

9 lines
227 B
Python

import sys
L = [ int(l[:-1]) for l in sys.stdin.readlines() ]
Z = zip(L, L[1:], L[2:])
M = [ a+b+c for (a,b,c) in Z]
Y = zip(M, M[1:])
P = [ [0,1][a<b] for (a,b) in Y ]
#print([(l,m,p) for (l,m,p) in zip(L,M,P)])
print(sum(P))