aoc2023/d09/run1_p.py

28 lines
583 B
Python

import sys
L = sys.stdin.read().splitlines()
S = 0
l = [0, 3, 6, 9, 12, 15]
#l = [1, 3, 6, 10, 15, 21]
#l = [10, 13, 16, 21, 30, 45]
#l = [-6, -9, -13, -18]
#l = [1, 12, 44, 109, 239, 501, 1018, 1996, 3753, 6743, 11566, 18954, 29723, 44682, 64492, 89471, 119345, 152950, 187896, 220211, 243991]
m = list(l)
latest=[]
latest.append(m[len(m)-1])
print(m)
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])
latest.append(m[len(m)-1])
print(m)
l = list(m)
S+=sum(latest)
#print(sum(latest))
print(S)