diff --git a/d09/run2.py b/d09/run2.py new file mode 100644 index 0000000..9e45d72 --- /dev/null +++ b/d09/run2.py @@ -0,0 +1,26 @@ +import sys + +L = sys.stdin.read().splitlines() +S = 0 +for report in L: + l = [int(r) for r in report.split(' ')] + + prem = [l[0]] + + 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]) + + prem.append(m[0]) + l = list(m) + + s = prem[0] + signe = -1 + for a in prem[1:]: + s+=(a*signe) + signe *= -1 + S+=s + + +print(S) \ No newline at end of file