re: Coding Interview: The Matchstick Game VIEW POST

re: Awesome, I've also built a similar game before when I was learning Angular. My solution is different though, I get the computer input by subtractin...

Thanks for the comment @devkumi ! If the human player takes the first turn (and therefore can't win, no matter what), then that's all you need to do!

This version forces the computer to play first, which means the computer needs to know whether the human player has made a mistake or not. If the human player makes a mistake, then the remainder, r = (count - 1) mod 4 is used to compute the right move for the computer. I think in your case it would be 4 - (count mod 4) because you're going up from 0 to 21.

code of conduct - report abuse