Probability Question relating prison break I am stuck in a question regarding a prisoner trapped in a cell with 3 doors that actually has a probability associated with each door chosen(say $.5$ for door $A$, $.3$ for door $B$ and $.2$ for door $C$). The first door leads to his own cell after traveling $2$ days, whereas the second door leads to his own cell after $3$ days and the third to freedom after $1$ day.
"A prisoner is trapped in a cell containig three doors. The first door leads to a tunnel that returns him to his cell after two days of travel. The second leads to a tunnel that returns him to his cell after three days of travel. The third door leads immediately to freedom.
a)  Assuming that the prisoner will always select doors 1,2,and 3 with probability 0.5, 0.3, 0.2 what is teh expected number of days until he reaches freedom?
b)  Assuming that the prisoner is always equally likely to choose among those doors that he not used, what is the expected number of days until he reaches freedom? (In this version, for instance, if the prisoner initially tries door1, then when he returns to the cell, he will now select only from doors 2 and 3) 
c)    For parts (a) and (b) find the variance of the number of days until the prisoner reaches freedom.
 "
In the problem I was able to find the $E[X]$ (Expected number of days until prisoner is free where X is # of days to be free). Where I get stuck is how to find the variances for this problem. I do not know how to find $E[X^2$ given door $1$ (or $2$ or $3$) chosen$]$. My understanding is that he does not learn from choosing the wrong door. Could anyone help me out? Thank you very much 

You can find the generating function for the discrete probability distribution.   For example, this will give the probabilities for stopping time N, as the corresponding coefficient of the $z^{-N+2}$ term.
$$p+\frac{q}{z}+\frac{(p*z+q)^2}{z*(z^3-p*z-q)}
$$
where $p$ is the probability for delay 2 (I guess door A) and $q$ for delay 3 (door B).
$$
\text{Prob}(N=1) = 0 \\
\text{Prob}(N=2) = p \\
\text{Prob}(N=3) = q \\
\text{Prob}(N=4) = p^2 \\
\text{Prob}(N=5) = 2pq
$$
