aoc2023/d09/run1.py

17 lines
311 B
Python
Raw Normal View History

2023-12-10 14:40:25 +00:00
import sys
L = sys.stdin.read().splitlines()
S = 0
for report in L:
l = [int(r) for r in report.split(' ')]
2023-12-10 14:53:22 +00:00
S+=l[-1]
2023-12-10 14:40:25 +00:00
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])
2023-12-10 14:53:22 +00:00
S+=m[-1]
2023-12-10 14:40:25 +00:00
l = list(m)
print(S)