Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Easy to read & understand solution in Clear category for The Final Stone by Wartem
def final_stone(stones: list[int]) -> int:
if not stones:
return 0
if len(stones) == 1:
return stones[0]
else:
nr1 = max(stones)
stones.remove(nr1)
nr2 = max(stones)
stones.remove(nr2)
new_stone = nr1 - nr2
stones.append(new_stone)
return final_stone(stones)
Sept. 10, 2022
Comments: