day 9, trivial recursion
This commit is contained in:
parent
492af0c576
commit
1d4c5f6f81
|
@ -0,0 +1,11 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
L = [list(map(int,l.split(' '))) for l in sys.stdin.read().splitlines()]
|
||||||
|
|
||||||
|
def extrapolate(L):
|
||||||
|
if all(not a for a in L):
|
||||||
|
return L+[0]
|
||||||
|
M = [b-a for a,b in zip(L,L[1:])]
|
||||||
|
return L+[L[-1]+extrapolate(M)[-1]]
|
||||||
|
|
||||||
|
print(sum(extrapolate(l)[-1] for l in L))
|
|
@ -0,0 +1,11 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
L = [list(map(int,l.split(' '))) for l in sys.stdin.read().splitlines()]
|
||||||
|
|
||||||
|
def extrapolate(L):
|
||||||
|
if all(not a for a in L):
|
||||||
|
return [0]+L
|
||||||
|
M = [b-a for a,b in zip(L,L[1:])]
|
||||||
|
return [L[0]-extrapolate(M)[0]]+L
|
||||||
|
|
||||||
|
print(sum(extrapolate(l)[0] for l in L))
|
Loading…
Reference in New Issue