a coins in the first and b in the second. In one move, you remove from the larger pile as many coins as the smaller pile holds. If the piles are equal, you take from the first one.
The game stops as soon as either pile is empty. Return the number of moves made by then.a=7, b=3 → 5
(7,3) → (4,3) → (1,3) → (1,2) → (1,1) → (0,1): five moves.
a=6, b=6 → 1
The piles are equal, so taking 6 from the first one empties it in one move.
a=0, b=4 → 0
The first pile is already empty, so no moves are needed.
a=7, b=3
5
Run checks the first 3 tests in your browser. Submit checks all 80 tests on the server, hidden ones included.