Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Climb the ladder solution in Clear category for The Stones by BrianMcleod
def stones(pile, moves):
safe = set(range(1, min(moves)+1))
for i in range(max(safe)+1, pile+1):
if not (safe & set([i-m for m in moves])):
safe.add(i)
return int(pile in safe) + 1
if __name__ == '__main__':
print("Example:")
print(stones(17, [1, 3, 4]))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert stones(17, [1, 3, 4]) == 2
assert stones(17, [1, 3, 4, 6, 9]) == 1
assert stones(99, [1]) == 2
print("Coding complete? Click 'Check' to earn cool rewards!")
Sept. 19, 2018