Two piles, take from one or equally from both
Two piles of stones hold 3 and 5 stones. On each turn a player either removes any positive number of stones from one pile, or removes the same positive number from both piles. The player who takes the last stone (leaving both piles empty) wins.
With best play, does the first or the second player win from (3, 5)? Justify it by finding the losing positions with small piles.
Show a hint
Positions (a, b) and (b, a) are the same. Work out the losing positions in increasing order: (0, 0) is losing for the player to move. Then find the smallest positions from which every move leads to a winning position.
Your answer
Solving needs a free account
Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.
Discussion
💡 Discussion rules
- No full solutions here. Hints and approaches only.
- Complexity, edge cases and intuition are the point.
- Interview experiences are welcome. Respect your NDAs.
Loading discussion…
Learn the concepts
The theory behind this question.