Reformulate the problem as a n-string of numbers in {0,1} and a position at which the action described in the problem is performed, and add 1 or 2 modulo n to the position according to the action. Say that a lap is complete for each time the position resets to 0 or 1. We will prove that the statement claim holds after at most two laps, after which the n-tuple cycles every three laps.
Say the rooster stops at a position in a certain lap if it performs an action at that position on that lap; otherwise, the rooster bypasses that position. We start with some immediate claims:
- The rooster has to stop at at least one of each two consecutive positions.
- The rooster stops at every position preceded by a 0. Indeed, if the numbers preceding that position are 00 then the rooster will definitely stop at the second zero, and if the numbers preceding that position are 10 then the rooster will either stop at 1 and go directly to the position or bypass 1 and stop at the second zero, and then stop at the position.
- Therefore, if the rooster bypasses a position, then it is preceded by a 1, and that 1 must be changed to a 0. This means that the rooster never bypasses a position in two consecutive laps.
- The rooster bypasses every position preceded by 01. Indeed, the rooster stops at either 1 or at 0, after which it will move to 1; at any rate, it stops at 1 and bypasses the position.
Our goal is to prove that, eventually, for every three consecutive laps, each position is bypassed exactly once. Then each position changes states exactly twice, so it gets back to its initial state after three laps. The following two lemmata achieve this goal:
Lemma 1. If the rooster stops at a certain position in two laps in a row, it bypasses it on the next lap, except for the n-string 1010…10, for which the problem statement holds.
Proof. If the rooster stopped at a position in lap t, then it is preceded by either (A) a 0 that was changed to 1, (B) a 11 that was changed to 01, or (C) a 10 in which the rooster stopped at 1. In case (A), the position must be preceded by 11 in the lap t+1, which becomes 01, so the rooster will bypass the position in the lap t+2. In case (B), the position will be bypassed in lap t+1.
Now we deal with case (C): suppose that the position was preceded by m occurrences of 10, that is, (10)m, on lap t and take m≤2n maximal. The rooster stopped at the 1 from each occurrence of 10, except possibly the first one.
First, suppose that n≥2m+2. After lap t, (10)m becomes either (00)m or 11(00)m−1 in lap t+1. In the latter case, initially we had 1(10)m, which became 011(00)m−1. It will then become a 01(11)m−1 in lap t+2, in which the rooster will bypass the position. In the former case, (10)m becomes (00)m, so it was either 00(10)m or 11(10)m in lap t, which becomes respectively a 1(00)m and 01(00)m in lap t+1, respectively. In the second sub-case, it becomes b 001(11)m−1 in lap t+2, and the position will be bypassed. In the first sub-case, it must be 11(00)m after which it becomes either 01(11)m or 1001(11)m−1. In any case, the position will be bypassed in lap t+2.
If n=2m+1, the possible configurations are
(10)m0→(00)m1→(11)m0→(10)m0
the rooster stops at the 1 from the first 10 because it was preceded by a 0.
(10)m1→(00)m0→0(11)m→1(01)m
or
(10)m1→11(00)m−10→01(11)m−11→(10)m1,
In any case, the position is bypassed in lap t+2.
If n=2m, the entire configuration is (10)m, m≥2. If the rooster did not stop at the first 1, it becomes 11(00)m−1 in the lap t+1, then 01(11)m−1 in the lap t+2, so the position is bypassed in this last lap. If the rooster stopped at the first 1, it becomes (00)m, then (11)m, then (01)m, then 10(00)m−1, then (11)m, and then it cycles between (11)m,(01)m and 10(00)m−1.
So, apart from this specific string, the rooster will stop at most two laps in a row at each position.
Lemma 2. If the rooster bypasses one position on a lap, then it stops at that position on the next two laps, with the same exception as lemma 1.
Proof. The position must be preceded by 1 in lap t. If it is preceded by 11, it changes to 10 in lap t+1. Then it becomes 00 because the 1 was already skipped in the previous lap, and the rooster will stop at the position in the lap t+2.
Now suppose that the position was preceded by (01)m on lap t and take m≤2n maximal. It becomes 10(00)m−1 or (00)m in lap t+1. In the former case, in lap t+2 it becomes either 00(11)m−1, after which the rooster stops at the position again, or (11)m, which we'll study later. In the former case, (00)m becomes (11)m or 01(11)m−1. In the latter case, the 0 was bypassed, so it must be stopped in the next lap, becoming (10)m. In the (11)m case, in order to bypass the position in lap t+2, it must become (10)m. All in all, the preceding terms are (01)m. Then, either 10(00)m−1 or (00)m, then either (11)m or 01(11)m−1, then (10)m. Then the second term in (01)m is 1, then 0, then 1, and then 0, that is, it changed three times. So we fall under the exception to lemma 1.
The result then immediately follows from lemmata 1 and 2.