Here is an elegant method due to Guibas and Odlyzko to obtain the expected time to reach a pattern, say HTH, for the first time. Let f(n) be the number of sequences of length n which do not have the pattern HTH. Let fp(n) be the number of sequences that have the pattern for the first time after n tosses. By dividing the sequences, we have
f(n)=fp(n+1)+fp(n+3).
Thus,
2nf(n)=2n+12fp(n+1)+2n+323fp(n+3).
If T is the time that the pattern occurs for the first time, this equality states that
P(T>n)=2P(T=n+1)+8P(T=n+3).
Show that if you sum this equality over all n you obtain
n=0∑∞P(T>n)=2+8=10.
Show that for any integer-valued random variable
E(T)=n=0∑∞P(T>n),
and conclude that E(T)=10.