Picking up Stones 2 - JavaLab

Picking up Stones 2




Pick up the stones each other. The person who picks up the last one wins the game. However, you can not pick up more than twice the amount of stones your opponent has taken.

Pick-up puzzle and Fibonacci sequence

For example, if there are 32 stones at first, the first picking up will be 1 to 31.
The computer uses the Fibonacci sequence (1, 1, 2, 3, 5, 8, 13, 21, 34, …..) to calculate the number of stones to pick-up.

Fibonacci sequence (created principle)
1
1 = 1
2 = 1 + 1
3 = 1 + 2
5 = 2 + 3
8 = 3 + 5
13 = 5 + 8
21 = 8 + 13
34 = 13 + 21
… …
n1 …
n2 …
n3 = n1 + n2

For example, if there are 32 stones, the maximum number of Fibonacci under 32 is 21, the maximum number of Fibonacci under 32-21=11 is 8, and 32-21-8=3 is the number of Fibonacci, so 32 = 21+8+3 Appears.
Thus, all numbers can be expressed as the sum of Fibonacci numbers, and the number at the bottom of each step in the sequence is greater than twice the number at the top. You can use this to beat the computer.
That is, 21 is greater than twice 8, and 8 is greater than twice as 3.

So if the number of stones is 21+8+3, the computer picks up 3 and tries to keep the Fibonacci sum. In this case, you will not be able to pick up 8. The computer keeps the sum of the Fibonacci numbers, and the winner who picks up the stone at the end is the computer. Not using this strategy is when the first number of stones is by chance Fibonacci number. In this case, the computer has no way, so the computer would pick one up and accidentally waits for the opponent to lose.

* Winning Strategy: Instead of a computer, you should keep the Fibonacci sum. Please find out more by doing it yourself…