<s>[INST] Expected number of turns in dice throwing I generated a transition probability matrix for a scenario where I throw five dice and set aside those dice that are sixes. Then, I throw the remaining dice and again set aside the sixes - then I repeat this procedure until I get all the sixes. $X_n$ here represents the number of dices that are sixes after n rolls.
$$\begin{pmatrix}\frac{5^5}{6^5} & \frac{3125}{6^5} & \frac{1250}{6^5} & \frac{250}{6^5} & \frac{25}{6^5} & \frac{1}{6^5}\\\ 0 & \frac{625}{6^4} & \frac{500}{6^4} & \frac{150}{6^4} & \frac{20}{6^4} & \frac{1}{6^4} \\\ 0& 0 & \frac{125}{6^3}& \frac{75}{6^3}& \frac{15}{6^3} & \frac{1}{6^3} \\\ 0 & 0& 0& \frac{25}{6^2}& \frac{10}{6^2}& \frac{1}{6^2}& \\ 0 & 0 & 0 & 0 & \frac{5}{6} & \frac{1}{6} \end{pmatrix}$$
I want to figure out how many turns it takes for me on average to get all sixes.
I'm not even sure where to start with this problem. Is it a right approach to write a program where I calculate $P^n$ and see when the 6th column all equals to 1? 
Any pointers would be greatly appreciated.
 [/INST] If $E_n$ is the expected number required when $n$ out of $5$ are already a six then clearly $E_5=0$ and you can write (dropping your final column) 
$$\begin{pmatrix}E_0 \\ E_1 \\ E_2  \\ E_3 \\ E_4  \end{pmatrix} =\begin{pmatrix}1 \\ 1 \\ 1  \\ 1 \\ 1  \end{pmatrix} + \begin{pmatrix}\frac{5^5}{6^5} & \frac{3125}{6^5} & \frac{1250}{6^5} & \frac{250}{6^5} & \frac{25}{6^5} \\ 0 & \frac{625}{6^4} & \frac{500}{6^4} & \frac{150}{6^4} & \frac{20}{6^4} \\ 0& 0 & \frac{125}{6^3} &\frac{75}{6^3}& \frac{15}{6^3}  \\ 0 & 0& 0& \frac{25}{6^2}& \frac{10}{6^2} \\ 0 & 0 & 0 & 0 & \frac{5}{6}  \end{pmatrix} \begin{pmatrix}E_0 \\ E_1 \\ E_2  \\ E_3 \\ E_4  \end{pmatrix}$$
which you can either solve by hand or, if $M$ is that square matrix,  find the row sums of $(I-M)^{-1}$ 
I think it should give you $E_5 \approx 13.023662$
</s>