Consider a sequence $1,-1,-1,-1,-1,-1,...,-1$. Start at the first element and move down the sequence according to the following rules:
- 1) If you jump from a $-1$ to another $-1$, turn the latter into a $0$.
- 2) If you would land on a $0$, skip it instead.
- 3) If you would reach the end of the sequence, wrap around instead.
For example, the first jump for the above sequence would leave the sequence unchanged, but the next would create a $0$ giving me $1,-1,0,-1,...,-1$. Assume I keep jumping around until only two elements are left
Call a jump from $-1$ to $1$ "nice". Given an initial sequence length $n$, how many "nice" jumps will I make, and from where?
Can you solve this with the $1$ in an arbitrary position, not just at the beginning?
Another example: Suppose we start with $-1,1,-1,-1$.
The first jump is nice and doesn't change the sequence. The second jump doesn't change anything either. The third takes us from the $-1$ in position 3 to the $-1$ in position 4, so the sequence is now $-1,1,-1,0$. The next three jumps - the second of which is nice - don't change the sequence, but after that I jump from the last $-1$ back around to the first one, changing it to a $0$, and I end with $0,1,-1,0$. For this sequence, I ended up making two "nice" jumps, both from index 1.
Is there a faster way to calculate this besides simulating it directly?