Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
fast solution in Clear category for The Stones by rafal.pawlowski
def stones(pile, moves):
truth_list = [True] + [False] * pile
for i in range(1,pile + 1,1):
temp = []
for move in moves:
if i <= move:
temp.append(False)
else:
temp.append(not(truth_list[i-move])) # not because we get winning/losing state of opponent
if any(temp):
truth_list[i] = True
else:
truth_list[i] = False
if truth_list[-1]:
return 1
else:
return 2
Feb. 21, 2019