Expected time to type a certain sequence I have a simplified version of the monkey typing ABRACADABRA problem and my approach to it does not yield the correct answer but I haven't been able to spot the error in my reasoning.
The problem is as follows. There is a typewriter with three characters on it, namely A, B and C. There is also a monkey hitting a key on the typewriter randomly such that after $n$ hits, the resulting sequence is $X_1X_2\ldots X_n$ where $(X_i)_i$ is an iid sequence with $P\{X_1 = A\} = P\{X_1 = B\} = P\{X_1 = C\} = 1/3$. Let $T$ be the random time (in this case also a stopping time) the sequence ABC first appears once the monkey starts typing. What is the expected value of $T$?
My approach was based on conditioning the expectation of $T$ on the first hits as follows.
\begin{align}
E[T] &= E[T\mid A]\frac{1}{3} + \underbrace{E[T\mid B]}_{E[T] + 1}\frac{1}{3} + \underbrace{E[T\mid C]}_{E[T] + 1}\frac{1}{3} \\
E[T\mid A] &= \underbrace{E[T\mid AA]}_{E[T\mid A] + 1}\frac{1}{3} + E[T\mid AB]\frac{1}{3} + \underbrace{E[T\mid AC]}_{E[T] + 2}\frac{1}{3} \\
E[T\mid AB] &= \underbrace{E[T\mid ABA]}_{E[T\mid A] + 2}\frac{1}{3} + \underbrace{E[T\mid ABB]}_{E[T] + 3}\frac{1}{3} + \underbrace{E[T\mid ABC]}_{3}\frac{1}{3} \\
\end{align}
Here I can solve for $E[T],E[T\mid A],E[T\mid AB]$ but I get $E[T] = 3$, which I know is not the right answer. Can someone point out where I am going wrong?
 A: My set up is quite similar to yours, but I get an expected value of $27$, which I believe is correct (by calculating it a different way).
Let $E$ be the expected number of steps until ABC appears.
Let $E_A$ be the expected number of steps after an A, and $E_{AB}$ be the expected number of steps after an AB.
Then, on the first step, either an A appears (probability 1/3) or it doesn't (probability 2/3).  If it doesn't, then we've take one step, and are back where we started, so
$$
E = \frac{1}{3}(1+E_A) + \frac{2}{3}(1+E).
$$
If the current step was an A, then one of three things happens: we type a B, an A, or neither, each with 1/3 probability.  Hence:
$$
E_A = \frac{1}{3}(1+E_{AB}) + \frac{1}{3}(1+E_A) + \frac{1}{3}(1+E).
$$
If we've reached the AB state, then one of three things happens: we type a C (and we're done), we type an A, or neither, each with probability 1/3.  Hence:
$$
E_{AB} = \frac{1}{3}(1) + \frac{1}{3}(1+E_A) + \frac{1}{3}(1+E)
$$
where $E$ is the expected number of steps until $ABC$, $E_A$ is the expected number of steps following an $A$, and $E_{AB}$ is the expected number of steps following $AB$. 
Solving this system, I find $E=27$. 
In your system, you have some expressions like $E(T)+2$ and $E(T)+3$ which should be $E(T)+1$, since you have already counted the other steps by earlier $E(T)+1$ expressions.
