Last stone standing

stones is a list of positive weights. Repeatedly take the two heaviest stones and smash them together: if they are equal both are destroyed, otherwise the lighter is destroyed and the heavier becomes the difference. Write last_stone(stones) that returns the weight of the final stone, or 0 if none remain.

last_stone([2, 7, 4, 1, 8, 1])  ->  1
last_stone([3, 3])              ->  0
last_stone([5])                 ->  5

The point is to practise simulating "take the two largest" with a max-heap via negation.

def last_stone(stones):
    ...