6
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ It could work without a trivial answer if primes didn't allow all the moves for compounds. $\endgroup$ – Nautilus Jul 24 at 15:19
7
$\begingroup$

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

https://ideone.com/SfMHqC

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.