Complex urn problem The urn contains 5 balls numbered $0, 1, 2, 3, 4$. We take a ball from the urn, write down its number and put it back into the urn. We repeat this action until the balls with numbers $1, 2, 3$ are drawn at least once. Calculate the probability that we repeat the operation $5$ times.
I would appreciate any hint for this exercise. I'm stuck with this one.
 A: Lets assume that we order the balls according to their selection order in a straight line . So , it become similar to obtaining $5$ digits numbers such that $[0,3,3,1,2] , [2,3,4,4,4]$ etc.
Because of the repetition allowed . The denominator will be $5^5$. It can be thought like how many $5$ digits number there are by using $(0,1,2,3,4)$ when repetition allowed . (and the first digit can be zero.)
Now , we should calculate that the number of events ($5$ digits number) when $1,2,3$ is used at least once. I can do it by inclusion -exclusion formula as you mentioned in comments. However , i want to give you much more easy and elegant way. It is called exponential generating functions.
By the reminder of OP , we know that the last digit must be $1,2,3$ to end the game. For now, lets assume that the last digit is $1$.
If $2,3$ is used at least once , their generating functions will be $x + \frac{x^2}{2} + \frac{x^3}{6} $.
If $0,4$ is used without restriction , their generating functions will be $1+x + \frac{x^2}{2}  $.
Then ,we should find the coefficient of the term $\frac{x^4}{4!}$ or find the coefficient of $x^4$ and multiply it by $4!$ in the expansion of these generating fuctions such that $(x + \frac{x^2}{2} + \frac{x^3}{6})^2 \times  (1+x + \frac{x^2}{2})^2  $.
Then , https://www.wolframalpha.com/input/?i=expanded+form+of+%281%2Bx%2B+x%5E2+%2F+2+%29%5E2+%28x+%2B+x%5E2+%2F+2+%2Bx%5E3%2F+6+%29%5E2+
$\color{red}{NOTE=}$ Do not forget that , we assume that $1$ is in the fifth digit , because if it were in some of preceding digit , the game will end uo without coming the fifth.This part was important to understand why we took the generating functions of the digits which appear at least once as $(x + \frac{x^2}{2} + \frac{x^3}{6})^{\color{red}{2}} $ instead of $(x + \frac{x^2}{2} + \frac{x^3}{6})^{\color{blue}{3}} $
We found that the coefficient of $x^4 = 110 $ by $\frac{55}{12} \times 4! =110$
However , there are $3$ possible end for our question such as $1,2,3$ . Hence we should multiply it by $3$ such that $3 \times 110 =330$
We found that the numerator will be $330$ and denominator $3125$ , so  answer is $0.1056  $
$\color{red}{NOTE=}$ I did not prefer bernoulli trial because it will be a little cumbersome . Moreover , i wanted to give you more powerful tool that you can use it more complex problems.
A: There are three possibilities for which number comes up on the fifth draw: $1$, $2$, or $3$. Let's suppose $3$ comes up last.
Now the result of the first four draws is a string of length $4$ from the set $\{0,1,2,4\}$ in which neither $1$ nor $2$ is missing. By the in-and-out formula (sometimes grandiloquently called the Principle of Inclusion and Exclusion) this is the total number of strings ($4^4$) minus the number with $1$ missing ($3^4$) minus the number with $2$ missing (also $3^4$) plus the number with both $1$ and $2$ missing ($2^4$). Finally we multiply by $3$ because the last number drawn could be $1$ or $2$ instead of $3$. So the numerator for your probability is
$$3\left(4^4-3^4-3^4+2^4\right)=330.$$
