d09 part one
This commit is contained in:
parent
4884b22b53
commit
710b64d2ee
|
@ -0,0 +1,3 @@
|
||||||
|
0 3 6 9 12 15
|
||||||
|
1 3 6 10 15 21
|
||||||
|
10 13 16 21 30 45
|
|
@ -0,0 +1,20 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
L = sys.stdin.read().splitlines()
|
||||||
|
S = 0
|
||||||
|
for report in L:
|
||||||
|
l = [int(r) for r in report.split(' ')]
|
||||||
|
m = list(l)
|
||||||
|
latest=[]
|
||||||
|
latest.append(m[-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])
|
||||||
|
|
||||||
|
latest.append(m[-1])
|
||||||
|
l = list(m)
|
||||||
|
S+=sum(latest)
|
||||||
|
|
||||||
|
print(S)
|
Loading…
Reference in New Issue