Rolling a die until two rolls sum to seven

To be clear: What follows assumes that the pair that adds to $7$ need not be consecutive. Thus, for example, I am assuming that the sequence $\{1,3,6\}$ ends the game in three rolls.

Let $E=E_0$ be the answer. If you have rolled a collection $S$ which contains no pair which adds to $7$ then let $E_S$ denote the expected number of rolls it will take from there. As every roll is equally probable, all that really matters is the size of $S$, so let $E_S=E_n$ if $S$ has $n$ elements. Of course the only possible $n$ are $\{0,1,2,3\}$.

We start with $E_3$. We note that rolling again has a $\frac 12$ chance of completing the $7$ and a $\frac 12$ chance of getting a useless duplicate, thus $$E_3=\frac 12\times 1+\frac 12 \times (E_3+1)\implies E_3=2$$

Now for $E_2$. As before we consider the next toss and write $$E_2=\frac 13\times 1+\frac 13 \times (E_2+1)+\frac 13 \times (E_3+1)\implies E_2=\frac 52$$

And $E_1$. As before $$E_1=\frac 16\times 1+\frac 16 \times (E_1+1)+\frac 46\times (E_2+1)\implies E_1=\frac {16}5$$

And then of course $$E=E_1+1=\frac {21}5$$


assuming that rolls need not be consecutive I.e. $1,3,6$ would be a terminating sequence of rolls since $1+6=7$ despite the $1$ and the $6$ not being adjacent.

I will admit I didn't read through all of your work, but this is the method I would approach the problem from. We can describe this using an absorbing markov chain with the following states:

$A_1 = $ Exactly one type of number has been seen so far. (This can be used as the starting state as we are guaranteed to enter this state after the first roll)

$A_2 = $ Exactly two types of numbers have been seen so far and they do not sum to seven. (The two numbers would be both from $\{1,2,3\}$, both from $\{4,5,6\}$, or one from each)

$A_3 = $ Exactly three types of numbers have been seen so far and no pair of which sum to seven. (The three numbers would be all from $\{1,2,3\}, \{4,5,6\}$ or from some combination thereof)

Finally, $B$ will be the endstate where we have some pair of numbers adding to seven. Convince yourself that these are indeed the only possible states.

From each state, you may either travel from $A_i$ to $A_{i+1}$, from $A_i$ to itself, or from $A_i$ to $B$ according to the following stochastic matrix with order of rows and columns as $A_1,A_2,A_3,B$

$$\begin{bmatrix} \frac{1}{6} & 0 & 0 & 0\\ \frac{2}{3} & \frac{1}{3} & 0 & 0\\ 0&\frac{1}{3}&\frac{1}{2}&0\\ \frac{1}{6}&\frac{1}{3}&\frac{1}{2}&1\end{bmatrix}$$

Recognizing this as an absorbing stochastic matrix, we rearrange the rows/columns into standard form: $\left[\begin{array}{c|c} I&S\\\hline 0&R\end{array}\right]$. We will instead use order $B,A_1,A_2,A_3$ for rows and columns

$$\begin{bmatrix} 1&\frac{1}{6}&\frac{1}{3}&\frac{1}{2}\\ 0&\frac{1}{6}&0&0\\ 0&\frac{2}{3}&\frac{1}{3}&0\\ 0&0&\frac{1}{3}&\frac{1}{2}\end{bmatrix}$$

In solving for the long-term state in the case of multiple possible absorbing states, we would calculate it using the limiting matrix: $\left[\begin{array}{c|c}I&S(I-R)^{-1}\\0&0\end{array}\right]$. Of course, in the current problem, there is only one ending state, so we know it will become $1$ in the entire top row and zeroes elsewhere. Still, the matrix $(I-R)^{-1}$ contains incredibly useful information and is referred to as the fundamental matrix for the markov chain. Depending on starting position, the sum of the column will give the expected number of turns until reaching an endstate. Alternatively, if the starting position is unknown, multiplying by an appropriate probability vector will give the desired information.

In our case: $I-R = \begin{bmatrix}\frac{5}{6}&0&0\\-\frac{2}{3}&\frac{2}{3}&0\\0&-\frac{1}{3}&\frac{1}{2}\end{bmatrix}$

$(I-R)^{-1} = \begin{bmatrix}1.2&0&0\\1.2&1.5&0\\0.8&1&2\end{bmatrix}$

Summing along the first column, we expect from having started in state $A_1$ it to take $1.2+1.2+.8 = 3.2$ turns to complete. Accounting for the fact that it takes one turn to enter state $A_1$, this gives a total expected time as $4.2$ turns.


As an aside, one can extract $Pr(N=n)$ from the stochastic matrix. Letting $A$ be the matrix in standard form and $v$ be the column vector with a $1$ in the second entry and zeroes elsewhere, you have the first entry of $A^{n-1}v - A^{n-2}v$ will give the probability that you arrive at the endstate on turn $n$ but not having already been there on turn $n-1$.