28 lines
576 B
Python
28 lines
576 B
Python
#!/usr/bin/env python3
|
|
|
|
CFS = [1, -1]*5 + [1]
|
|
|
|
def main(cfs):
|
|
seq = getseq(cfs)
|
|
py = pyramid(seq)
|
|
return sum(op(n, py) for n in range(1, len(cfs)))
|
|
|
|
def getseq(cfs):
|
|
return [sum(c*n**pw for pw, c in enumerate(cfs))
|
|
for n in range(1, len(cfs))]
|
|
|
|
def pyramid(seq):
|
|
r = [seq]
|
|
for i in range(len(seq)-1):
|
|
lvl = []
|
|
for j in range(len(r[i])-1):
|
|
lvl.append(r[i][j+1] - r[i][j])
|
|
r.append(lvl)
|
|
return r
|
|
|
|
def op(n, py):
|
|
return sum(py[i][n-i-1] for i in range(n))
|
|
|
|
#print(main([0,0,0,1]))
|
|
print(main(CFS))
|