Suppose a bucket contains n balls. In each turn one removes some balls k from the basket. If first player removes even-number balls then second player must removes odd-number of balls and vice-versa. The winner is who plays the last turn and makes the bucket empty. The game is tie when it is impossible to make the bucket empty. Assume both players play optimally. Here optimally means a player plays in a way so that the opponent player does not win. 0

  • $\begingroup$ Does the first person have to do the opposite of what the second player did? In that case all the first player's moves have one parity and all the second player's moves have another. This is not necessarily nim, as the moves available to each player are different. Why doesn't the first player take all the balls and win? $\endgroup$ Jun 19, 2014 at 3:34
  • $\begingroup$ What exactly is your question? Are you looking for the values of the games, just the winner, an optimal strategy, $\ldots$? $\endgroup$
    – Théophile
    Jun 19, 2014 at 3:40
  • $\begingroup$ I want to know the winner along with optimal strategy given different values of n $\endgroup$
    – user157920
    Jun 19, 2014 at 3:42

1 Answer 1


Hint: think first about what happens when $n$ is odd. The strategy is rather simple then. There is no reason that $n$ is limited to small numbers. You can compute the winner in one line.

  • $\begingroup$ And if you remove odd or even balls to begin with. Then you have all the cases and you can solve it. $\endgroup$ Jun 19, 2014 at 3:47
  • $\begingroup$ sir how to find the winning strategy then? $\endgroup$
    – user157920
    Jun 19, 2014 at 3:50
  • $\begingroup$ if n is odd then second player wins always but what about when n is even? $\endgroup$
    – user157920
    Jun 19, 2014 at 3:52
  • $\begingroup$ As Carlos says, now think about Alice starting with an odd number of balls and also with her starting with an even number. What is the parity of the number of balls after each move? $\endgroup$ Jun 19, 2014 at 3:58
  • $\begingroup$ if she starts with an odd number of balls then even-odd=odd which will be a winning move for her and if she starts with an even number of balls then even-even=even which will be a losing move for her/n is this right? $\endgroup$
    – user157920
    Jun 19, 2014 at 4:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .