# How many different patterns of heads and tails can we obtain after a number of moves?

There are eight coins in a row, all showing heads. In each move, we can flip over two adjacent coins provided that they are both showing heads or both showing tails. How many different patterns of heads and tails can we obtain after a number of moves?

Im not sure how to solve this, hints aswell as solutions would be appreciated

Taken from the 2013 BIMC https://chiuchang.org/wp-content/uploads/sites/2/2018/01/2013-IWYMIC-Individual.x17381.pdf

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.

I assume that in each move, one may flip but doesn't have to. Of course then, we have the case of eight heads as a possible pattern after $$k \geq1$$ number of moves. If for $$k=1$$ we choose to flip, there are $$\binom{7}{1}=7$$ ways to do so(there are $$7$$ adjacent pairs). For $$k=2$$ all the $$8$$ previous patterns are possible, so we only need to add the cases for which one chose to flip both for $$k=1$$ and $$k=2$$ and did not flip the same pair back and forth(ending up with eight heads again). So we want to choose two adjacent pairs out of seven, but then discount the choices where the two pairs overlap, which happens when three adjacent coins are "covered" by the two pairs. There are $$\binom{7}{2}=21$$ ways to choose adjacent pairs, and $$\binom{6}{1}=6$$ ways to choose overlaps(there are $$6$$ adjacent triplets), thus we end up with $$21-6=15$$ new patterns for $$k=2$$.

For $$k=3$$,again only considering new patterns, there are $$\binom{7}{3}=35$$ ways to choose three adjacent pairs. The overlaps can take one out of two forms. One of them is to take two adjacent triplets, where the one closest to the beginning of the row corresponds to two overlapping adjacent pairs, and the other one to one adjacent pair in the last two places. E.g. the two triplets at places $$\{1,2,3\}$$ and $$\{5,6,7\}$$ would mean that the pairs are $$\{1,2\}$$, $$\{2,3\}$$ and $$\{6,7\}$$, and two triplets at places $$\{1,2,3\}$$ and $$\{2,3,4\}$$ would mean that the pairs are $$\{1,2\}$$, $$\{2,3\}$$ and $$\{3,4\}$$. The other form of overlap consists of two quadruplets, where the one closest to the beginning of the row has one pair in the first two places, and the other quadruplet has two overlapping pairs in the last three places. So e.g. $$\{1,2,3,4\}$$ and $$\{5,6,7,8\}$$ would mean that the pairs are $$\{1,2\}$$, $$\{6,7\}$$ and $$\{7,8\}$$, and $$\{1,2,3,4\}$$ and $$\{2,3,4,5\}$$ would mean that the pairs are $$\{1,2\}$$, $$\{3,4\}$$ and $$\{4,5\}$$. There are $$\binom{6}{2}=15$$ ways to choose the triplets and $$\binom{5}{2}=10$$ ways to choose the quadruplets, thus we end up with $$35-15-10=10$$ new patterns for $$k=3$$.

For $$k=4$$ we only get the all tails case as a possible new one. Thus if $$f(k)$$ gives the number of possible patterns after move $$k$$ we have $$f(1)=8, f(2)=23, f(3)=33, f(k)=34, k \geq 4.$$