Ann and Bob play alternately on a pile of chips. On each play, either 1, 2 or 3 chips can be removed except if the number of chips is a prime number. In that case either 1, 2, 3, 4 or 5 chips can be removed.The person, who removes the last chip is the winner. There are 100 chips on the pile. Ann starts. Determine a winning strategy for one of the players.
1 Answer
$\begingroup$
$\endgroup$
1
It seems like you force a win if you can leave behind a multiple of 4. So the first player is guaranteed to lose because he cannot leave behind a multiple of 4. Whatever amount player 1 takes (x), player 2 should take 4 - x.
Here's a little Python program to test it yourself:
https://repl.it/repls/ScientificIdenticalPixels
And here's C++ code written by user @im_so_meta_even_this_acronym
-
$\begingroup$ Would you mind adding my code for C++ users? :) ideone.com/SfMHqC $\endgroup$ Commented Jul 23, 2019 at 22:28