PROJECT EULER · #0993
Banana Beaver
A beaver plays a game on an infinitely long number line.
When the game starts, the beaver is at position
At each step, the beaver will do the following according to the bananas it sees at positions
- If there is a banana at
and another banana at , then the beaver will pick up a banana at position , and then move itself to position . - If there is a banana at
but there is no banana at , then it will pick up a banana at and move itself to position . - If there is no banana at
but there is a banana at , then it will move a banana from position to position and move itself to position . - If there is no banana at
and no banana at , then the beaver checks whether it still carries at least three bananas. If so, then it will drop a banana at each of the three positions and move itself to position ; otherwise the game ends.
For example, if
Similarly, if
Let
You are given
Find
Write-up coming later
The complete problem is available here. An approach, code, and answer will be added later.