Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Stair Steps by Moff
def calc_paths(nums, paths, x, i):
if i >= len(nums):
return
paths[i] = max(nums[i] + x, paths[i])
calc_paths(nums, paths, paths[i], i + 1)
calc_paths(nums, paths, paths[i], i + 2)
def checkio(nums):
nums = [0] + nums + [0]
paths = [-float('inf')] * len(nums)
calc_paths(nums, paths, 0, 0)
return paths[-1]
Aug. 5, 2015