aoc2023/d09/run1.py

17 lines
311 B
Python

import sys
L = sys.stdin.read().splitlines()
S = 0
for report in L:
l = [int(r) for r in report.split(' ')]
S+=l[-1]
while not all(v == 0 for v in l):
m = []
for i in range(0,len(l)-1):
m.append(l[i+1] - l[i])
S+=m[-1]
l = list(m)
print(S)