TITLE: Chance of three same consecutive answers in A/B/C/D test
QUESTION [5 upvotes]: I am facing the following problem:

What is the probability that there will be at least three same consecutive right answers in a $n$-question A/B/C/D test?

I have started with $10$ questions while trying to solve this, so there are $4^{10}$ possible sequences. Now our three same results can begin at the first through the eighth place ($n-2$) because at the ninth place it would be $9-10-11$. For each of these possibilities there can be $4^{10-3} = 4^7$ combinations of $7$ remaining positions. So that's $8 \cdot 4^7$, and now we have to multiply by $4$ because there can be three or more As, Bs, Cs or Ds. That gives us $$\frac{8 \cdot 4^7 \cdot 4}{4^{10}}$$ which simplifies to $8/4^2 = 1/2 = 50\%$.
I have checked the result practically with Python code with $100,000$ attempts, and I got about $38514/100000 = 0.38514 = 38.514\%$, which is not even remotely close to my result.
Do you have any idea where I went wrong?

REPLY [2 votes]: Alternatively, the question can be formulated as a problem of computing the probability of absorption in a Markov chain. 
We can assign a state $i \in \{1, 2, 3\}$ to any sequence of characters from $\{A, C, B, D\}$ , which represents the fact that the last $i$ consecutive characters are the same. Once the chain reaches the state $3$, the sequence is classified as 'wrong' and the chain remains in this state. Such a chain has the transition matrix $\mathbf{P}  = \{p_{ij}\}$, where $p_{ij}$ is the transition probability from $i$ to $j$, 
$$ \mathbf{P} = 
    \begin{pmatrix}
    3/4 & 1/4 & 0 \\
    3/4 & 0 & 1/4 \\
    0 & 0 & 1 \\
    \end{pmatrix}
$$
and the initial distribution $p_1^T = (1, 0 , 0)$. Then
$$p_{10}^T = p_1^T \, \mathbf{P}^{9} \approx (0.5108, 0.1347, 0.3545)^T.  $$