Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D

Problem: Nim with three piles of sizes 1, 2 and 3. A move removes any positive number of stones from one pile. The player who takes the last stone wins (normal play). How many of the first moves are winning moves (moves after which the player to move next is in a losing position)?

  1. A. 1
  2. B. 2
  3. C. 3
  4. D. 0

Correct answer: D. 0

A move is winning when it leaves the opponent in a position with no winning reply. In Nim this is decided by the XOR of pile sizes. Counting moves that merely reduce the total stones is a different criterion.

More Coding Interview Problems questions

Exams that ask this topic