MathLabs

Problem 5

The Bank of Bath issues coins with an HH on one side and a TT on the other. Harry has nn of these coins arranged in a line from left to right. He repeatedly performs the following operation: if there are exactly k>0k>0 coins showing HH, then he turns over the kkth coin from the left; otherwise all coins show TT and he stops. For example, if n=3n=3, the process starting with THTTHT is THT→HHT→HTT→TTTTHT\to HHT\to HTT\to TTT, which stops after three operations. (a) Show that, for each initial configuration, Harry stops after a finite number of operations. (b) For each initial configuration CC, let L(C)L(C) be the number of operations before Harry stops. Determine the average value of L(C)L(C) over all 2n2^n possible initial configurations.
Step 3 of 6: Transform a final head
In plain words

Counting heads from the left becomes counting tails from the right.

k−1 heads in the first n−1 coins ⟹flip the kth left coin=the (n−k)th right tailk-1\text{ heads in the first }n-1\text{ coins }\Longrightarrow\text{flip the }k\text{th left coin}=\text{the }(n-k)\text{th right tail}
Detailed analysis

Now suppose the last coin is HH. If the first n−1n-1 coins contain k−1k-1 heads, the total is kk, so the rule flips the kkth coin from the left; this is among the first n−1n-1 coins. Those coins contain n−kn-k tails, and the selected position is the (n−k)(n-k)th tail counted from the right. Thus, after reversing the first n−1n-1 positions and exchanging HH with TT, the operation is exactly the original rule, with the target changed from all tails to all heads.