Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Stones by mortonfox
def stones(pile, moves):
min_moves = min(moves)
winner = []
for i in range(pile + 1):
winner.append(1 if i > min_moves and any(i - m > 0 and winner[i - m] == 2 for m in moves) else 2)
return winner[pile]
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: