Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Golden Pyramid by Amachua
"""
This function will first change the tupple into a list which isn't immutable
Next it will compute, for each column of the pyramid the maximum value of each case.
"""
def count_gold(pyramid):
pyramid = [list(p) for p in pyramid]
for j in range(len(pyramid)-2, -1, -1):
for i in range(len(pyramid[j])):
pyramid[j][i]+= pyramid[j+1][i] if pyramid[j+1][i] > pyramid[j+1][i+1] else pyramid[j+1][i+1]
return pyramid[0][0]
May 1, 2014
Comments: