aoc2023/d09/run1_s.py

13 lines
320 B
Python
Raw Normal View History

2024-06-07 01:12:49 +00:00
import sys
L = [list(map(int,l.split(' '))) for l in sys.stdin.read().splitlines()]
def extrapolate(L):
if all(not a for a in L):
return L+[0]
M = [b-a for a,b in zip(L,L[1:])]
return L+[L[-1]+extrapolate(M)[-1]]
for l in L:
print(extrapolate(l)[-1])
#print(sum(extrapolate(l)[-1] for l in L))