Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Golden Pyramid by yukirin
def count_gold(pyramid):
result = [list(steps[:]) for steps in pyramid]
for i in range(len(pyramid[1:])):
for j in range(len(pyramid[i + 1])):
left = result[i][j - 1] if j > 0 else 0
right = result[i][j] if j <= i else 0
result[i + 1][j] += (left if left > right else right)
return max(result[-1])
April 14, 2015