Clarification on expected number of coin tosses for specific outcomes. As seen in this question, André Nicolas provides a solution for 5 heads in a row.
Basically, for any sort of problem that relies on determining this sort of probability, if the chance of each event is 50/50, then no matter what the composition of values, the linear equation would be the same?
For example, in the case of flipping 5 coins, and wanting to find out how many flips are needed for 4 consecutive tails followed by a head, is the same form as trying to find how many flips for 5 heads? 
specifically:
$$x=\frac{1}{2}(x+1)+\frac{1}{4}(x+2)+\frac{1}{8}(x+3)+\frac{1}{16}(x+4)+\frac{1}{32}(x+5)+\frac{1}{32}(5).$$
Where $\frac{1}{32}(x+5)$ denotes the last flips chance of landing a tails after 4 heads in a row (.5*.5*.5*.5*(P(tails))
If I was using an unfair coin in the same example as above (HHHHT) with a 60% chance to land on heads, would the equation be:
$$x=\frac{1}{2}(x+1)+\frac{1}{4}(x+2)+\frac{1}{8}(x+3)+\frac{1}{16}(x+4)+\frac{1}{40}(x+5)+\frac{1}{40}(5).$$

Suppose that the probability of head is $p$, and the probability of tail is $1-p$, where $0\lt p\lt 1$.   
Let $x$ be the expected number of tosses until we first get the sequence HHHHT.  As in the solution in the previous problem, we will obtain a linear equation for $x$. 
If the first toss is T, (probability $1-p$) our expectation is $1+x$. That contributes $(1-p)(1+x)$ to the mean.
Similarly, first two tosses HT contributes $p(1-p)(2+x)$ to the mean, and HHT contributes $p^2(1-p)(3+x)$, and HHHT contributes $p^3(1-p)(4+x)$. Of course HHHHT  contributes $p^4(1-p)(5)$. 
But computing the contribution of HHHHH involves an additional idea.   
For HHHHH, the contribution is $p^5 (5+w)$ where $w$ is the mean waiting time for a tail. That is a standard problem (mean of a geometric distribution) and we have $w=\frac{1}{1-p}$.
Alternately, we can forget about HHHHT, and HHHHH, and note that HHHH contributes $p^4(4+w)$ to the mean. 
Remark: For more general problems of this character, it is easier to set up an appropriate set of states $s_1, s_2,\dots, s_n$ and let $e_1,e_2,\dots,e_n$ be the expected (further) costs when we are in the various states. We can fairly often reduce the problem to solving a set of linear equations in the $e_i$. 
