How many different patterns of heads and tails can we obtain after a number of moves?
This is quite a tricky question! Consider this seemingly different question:
There are eight coins in a row, alternating between heads and tails, like
HTHTHTHT
. In each move, we can flip over two adjacent coins, provided they show opposite faces. How many patterns are reachable?
This problem is a bit easier, once you play around with it. The act of flipping HT
to TH
, or vice versa, is equivalent to switching the two coins. By doing enough of these switches, you can shuffle the coins so the four heads appear at any desired place in the line. Furthermore, there will always be exactly four heads, so these are the only reachable positions. Therefore, the number of reachable patterns is the number of patterns with exactly four heads, which is $\binom{8}4=70$.
It turns out that this is exactly the same problem as the one given, just in disguise. For each state, $s$, in the original, define its "shadow" to be the state given by flipping over every other coin in $s$, starting with the second coin from the left. The "shadow" of the initial state in your problem, HHHHHHHH
, is HTHTHTHT
, which is initial state in my variant. Furthermore, as the states change the your problem, their "shadows" change exactly as they do in my variant. Therefore, the reachable states in the original are the shadows of the reachable states in the variant. In particular, the original also has $\binom{8}4=70$ reachable states.