Solution (source code)

= Solution

During any year, repeats may be ignored until the first non-repeat outcome. Conditional on that event, the chance of progressing is
$$
\frac r{p+r}=\frac r{1-q}.
$$
The student must progress successfully through all three years. By the <Markov property>, the required probability is therefore
$$
\boxed{\left(\frac r{p+r}\right)^3.}
$$