Stone Game (100 pts)
Last updated
Last updated
Author: farisv
Welcome to the Stone Game. Take turns with the computer to pick stones from any set. Remove as many as you want, but the one who takes the last stone wins. Plan your moves carefully and try to outsmart the computer.
nc 68.183.177.211 10001
In this challenge, we are given a service where we can play a game against the computer.
Thankfully, this service has a vulnerability where it actually accepts "0" as the number of stones to take. It means that after we take 0 stone, the computer is now forced to take some stones and thus make the "nim sum" of the stone not zero. After that, we have a winning strategy.
Here's the full code.
Flag: CJ{why_I_allowed_zero_:(}
This game resembles a strategy game called Nim (). Mathematically, we have a winning-guaranteed strategy if the "nim sum" of the stones is not zero and it's our turn. Unfortunately though, here we go first and the inital "nim sum" is zero. That means it's the computer that has a winning strategy. Even if we do all the optimal moves explained in the Wikipedia link above, we'd still lose assuming that the computer also choose the optimal moves every time.