TITLE: Expected number of tosses for two coins to achieve the same outcome for five consecutive flips
QUESTION [15 upvotes]: Consider two unbiased coins. Toss both until last 5 sequence outcome are same.
That means we stop when output of the sequence of both are as follows: 
HTTHTHHTH , HHTTTHHTH. 
What is the expected number of trials?

REPLY [18 votes]: Here's a different approach that simultaneously generalizes the solution.  
As Didier and David have pointed out, the problem is equivalent to finding the expected number of flips required for a fair coin to achieve five consecutive heads for the first time.  Let $X_n$ denote the toss on which a fair coin achieves $n$ consecutive heads for the first time.  The analysis is just as easy if the coin isn't fair, though, so let's suppose that the coin has probability $p$ of being heads.
Suppose the coin has just achieved $n-1$ consecutive heads for the first time.  Then, with probability $p$, the coin achieves $n$ consecutive heads for the first time on the next flip, and with probability $1-p$, the process restarts after the next flip.  Mathematically, this is saying that $$\begin{align}E[X_n|X_{n-1}] &= p (X_{n-1}+1) + (1-p)(X_{n-1} + 1+ E[X_n])\\ &= X_{n-1} +1+ (1-p)E[X_n].\end{align}$$
Applying the law of total expectation, we have $$\begin{align} E[X_n] &=  E[X_{n-1}] +1 + (1-p)E[X_n] \\ \Rightarrow E[X_n] &= \frac{E[X_{n-1}] +1}{p}.\end{align}$$
Now we have a nice recurrence for $E[X_n]$.  Since $E[X_0] = 0$, unrolling this recurrence shows that 
$$\begin{align}E[X_1] &= \frac{1}{p}, \\ E[X_2] &= \frac{1 + p}{p^2}, \\ E[X_3] &= \frac{1 + p+p^2}{p^3},\end{align}$$ and in general 
$$E[X_n] = \frac{1+p+p^2+\cdots + p^{n-1}}{p^n}.$$
Using the formula for the partial sum of a geometric series, this expression simplifies to 
$$\begin{align}E[X_n] &= \frac{1-p^n}{(1-p)p^n} \\ &= \frac{p^{-n}-1}{1-p}.\end{align}$$
In the case of a fair coin we have $p = 1/2$, and so  $$E[X_n] = 2^{n+1}-2.$$
Thus the answer to the OP's question is $E[X_5] = 2^6-2 = 62,$ as David Mitra has already shown.

This approach also handles the generalization of the OP's question in which the two coins being tossed do not necessarily have the same probability of being heads.  Suppose one has probability $p_1$ of being heads, the other has probability $p_2$ of being heads, and we toss them until the last $n$ flips are the same.  For a single flip, they are the same if they both come up heads, with probability $p_1 p_2$, or both tails, with probability $(1-p_1)(1-p_2)$.  Thus the probability that they are the same on a single flip is $1 - p_1 - p_2 + 2p_1p_2$.  Tossing these two coins until the last $n$ flips are the same is the same problem as tossing a single coin with heads probability $1 - p_1 - p_2 + 2p_1p_2$ until we see $n$ consecutive heads, and so the formula above for $E[X_n]$ tells us that the expected number of tosses of the two coins until the last $n$ flips are the same is $$E[X_n] = \frac{(1-p_1 - p_2+ 2p_1p_2)^{-n}-1}{p_1 + p_2 - 2p_1p_2}.$$