Thinking about a probability question using Markov chains The problem is part (b):
1.4.7. A pair of dice is cast until either the sum of seven or eigh appears.
 (a) Show that the probability of a seven before an eight is 6/11.
 (b) Next, this pair of dice is cast until a seven appears twice or until each of a six and eight has appeared at least once. Show that the probability of the six and eight occurring before two sevens is 0.546.
I would like to try to solve this problem using Markov chains, but I'm encountering a dilemma. To calculate the probability, I would need to multiply down the branches that lead to a terminating state, and then sum all of those branches. But I have loops in my diagram, so I'm not sure how to account for the fact that I could remain in a state for an indefinite number of rolls:
[I only drew the branches corresponding to rolling a 6, but there are of course the two other branches (and sub-branches) for rolling a 7 or 8.]

If that's hard to read, here is a higher resolution. This is my chain of reasoning: We start out in a state of not having a 6, 7, or 8 yet. We could stay here indefinitely. Rolling a 6 takes us to the next state. We could also stay here indefinitely, or roll an 8 and get an accept state. Or we could roll a 7. At that state, we could roll another 7 and get an accept state or roll and 8 or indefinitely roll a 6 (or any other number). All of those probabilities are noted in the transitions.
How do I account for these possibilities?
 A: We can think of the experiment as follows. At the start, we have a biased three-sided coin that outputs $6,7,8$ with probabilities $5/16,3/8,5/16$; we don't care about the other outcomes, so we can just ignore them. After we see $6$, we don't care about $6$, so the probabilities of $7,8$ are $6/11,5/11$.
Here are the possible runs of the game:


*

*$6,8$ or $8,6$: probability $2\cdot 5/16 \cdot 5/11$.

*$6,7,8$ or $8,7,6$: probability $2\cdot 5/16 \cdot 6/11 \cdot 5/11$.

*$6,7,7$ or $8,7,7$: probability $2\cdot 5/16 \cdot 6/11 \cdot 6/11$.

*$7,6,8$ or $7,8,6$: probability $2\cdot 3/8 \cdot 5/16 \cdot 5/11$.

*$7,6,7$ or $7,8,7$: probability $2\cdot 3/8 \cdot 5/16 \cdot 6/11$.

*$7,7$: probability $3/8\cdot 3/8$.


Summing up the relevant cases, the probability that both $6,8$ appear before $7$ appears twice is $4225/7744$.
A: Others have already given some excellent answers to this problem, and the original post was over two years ago.  Nevertheless, I would like to show how the problem can be solved by using an exponential generating function.
We know the last number rolled must be a 6 or an 8, and by symmetry we know these two cases are equally likely, so let's suppose the last number is an 8 in order to simplify the problem a bit.  Then an acceptable sequence of rolls starts with $n >0$ rolls consisting of no 8's, at least one 6, and at most one 7, followed by a final 8.  Let $a_n$ be the probability of rolling the initial sequence (not including the final 8), for $n \ge 0$. Any acceptable initial sequence is the "labeled product" of 


*

*any number of rolls which are not 6's, 7's, or 8's

*at least one roll of 6

*at most one roll of 7


so the exponential generating function for $a_n$ is
$$\begin{align}
f(x) &= \sum_{n=0}^{\infty} \frac{1}{n!} a_n x^n \\
&= \left(1 + qx + \frac{q^2}{2!} x^2 + \frac{q^3}{3!} x^3 + \dots \right) \left( p_6 x + \frac{p_6^2}{2!} x^2 + \frac{p_6^3}{3!} x^3 + \dots \right) (1 + p_7x) \\
&= e^{qx} (e^{p_6 x} -1) (1+ p_7 x)
\end {align}$$
where $q$ is the probability of rolling anything but a 6, 7, or 8, and $p_k$ is the probability of rolling a $k$.  The numerical values are $q = 20/36$, $p_6 = 5/36$, and $p_7 = 6/36$.  
The probability of rolling an acceptable initial sequence of length $n$ followed by an 8 is $a_n p_8$, so the total probability of any acceptable initial sequence followed by an 8 is
$$p = \sum_{n=0}^{\infty} a_n p_8$$
We can use the following trick to extract this sum from $f(x)$.  Since 
$$n! = \int_0^{\infty} e^{-x} x^n \; dx$$
we have
$$p = \sum_{n=0}^{\infty} a_n p_8 = \int_0^{\infty} f(x) \; e^{-x} \; p_8 \; dx = \int_0^{\infty} e^{qx} (e^{p_6 x} -1) (1+ p_7 x) \; e^{-x} \; p_8 \; dx $$
Evaluating the integral yields 
$$p = \frac{4225}{15488}$$
which is the probability of an acceptable sequence of rolls ending in 8.
The answer to the original problem, where the final roll may be either a 6 or an 8, is then
$$2p = \frac{4225}{7744}$$
