Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
"The Stones" solution in Clear category for The Stones by Dmitrij_Protopopov
def stones(pile, moves):
L = {1}
for i in range(2, pile+1):
if not({i-j for j in moves} & L): L = L | {i}
return (pile in L)+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. 20, 2018
Comments: