GATE Computer ScienceHardGATE CS

In the game of Nim with piles of 9, 12, 17, 21, 30 and 6 stones, a move removes any positive number of stones from a single pile. How many different winning moves does the first player have (moves after which the position has Nim-sum 0)?

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

Correct answer: C. 3

The Nim-sum of the piles is 9 ⊕ 12 ⊕ 17 ⊕ 21 ⊕ 30 ⊕ 6 = 25. A move on pile p is winning exactly when p ⊕ 25 < p: this holds for 17 (to 8), 21 (to 12) and 30 (to 7), but not for 9, 12 or 6. So there are 3 winning moves.

More Discrete Mathematics questions

Exams that ask this topic