Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Golden Pyramid by light2happy.718
import functools
def count_gold(pyramid):
"""
Return max possible sum in a path from top to bottom
"""
@functools.lru_cache(maxsize=None)
def search(level, room):
try:
gold = pyramid[level][room]
except IndexError:
return 0
else:
left = search(level+1, room)
right = search(level+1, room+1)
return gold + max(left, right)
return search(0, 0)
May 24, 2015
Comments: