Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Recursive solution with arguments row and col initialized to 0. solution in Clear category for Golden Pyramid by Phil15
def count_gold(pyramid, row=0, col=0):
"""Return max possible sum in a path from top to bottom"""
if row==len(pyramid)-1:
return pyramid[row][col]
return pyramid[row][col] + max(
count_gold(pyramid, row+1, col),
count_gold(pyramid, row+1, col+1))
April 7, 2018
Comments: