Pyramid kata
This commit is contained in:
parent
28346edaf8
commit
d3f5000dad
1 changed files with 10 additions and 0 deletions
10
pyramid.py
Normal file
10
pyramid.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
def longest_slide_down(pyramid):
|
||||||
|
paths = [0]
|
||||||
|
for step in pyramid:
|
||||||
|
print(paths)
|
||||||
|
paths = [paths[0]+step[0]] + list([max(da+a,db+b) for da,a,db,b in zip(step[:-1],paths[:-1],step[1:],paths[1:])]) + [paths[-1]+step[-1]]
|
||||||
|
print(paths)
|
||||||
|
|
||||||
|
return max(paths)
|
||||||
|
|
||||||
|
print(longest_slide_down([[3],[7,4],[2,4,6],[8,5,9,3]]))
|
Loading…
Reference in a new issue