PROJECT EULER · #0939
Partisan Nim
Two players A and B are playing a variant of Nim.
At the beginning, there are several piles of stones. Each pile is either at the side of A or at the side of B. The piles are unordered.
They make moves in turn. At a player's turn, the player can
- either choose a pile on the opponent's side and remove one stone from that pile;
- or choose a pile on their own side and remove the whole pile.
The winner is the player who removes the last stone.
Let
For example
| Nr. | Piles at the side of A | Piles at the side of B |
|---|---|---|
| 1 | none | |
| 2 | none | |
| 3 | none | |
| 4 | none | |
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | none | |
| 9 | none |
Find
Write-up coming later
The complete problem is available here. An approach, code, and answer will be added later.