[Math] Probability of creating a password with 2 digits and 6 letters

combinatoricsprobability

I'm having a little trouble with an exercise, due to a flawed logic that I need to fix. I apologize in advance if anything of this is silly, or for my language as I'm not a native English speaker.

I have an alphabet of 21 letters and 10 digits (0-9) and I need to calculate the probability of creating a password that has a total length of 8 characters, with exactly 2 digits and 6 letters.

First, I defined the total of outcomes, which are $31^8$: I've imagined 8 boxes, each one can have 31 (the total length of the alphabet) possible characters.

Now, for the likely outcomes I've imagined to calculate all the ways to take 2 digits out of 10 ($\binom{10}{2}$) and multiply them for the possible ways to take 6 letters from 21 total letters($\binom{21}{6}$). I thought of combinations because no order is apparently required.

The solution is different on these outcomes: I was right on $31^8$ but the likely outcomes are calculated as $\binom{8}{2}*10^2*21^6$ for a result of
$P(E) = \frac{\binom{8}{2}*10^2*21^6}{31^8}$.

I can't understand this solution, nor what I'm doing wrong. Can anybody help me out?

Best Answer

Let's think about how you obtained $31^8$ possible outcomes. You realized that there were $31$ choices for each of the eight positions in the password, including $21$ letters and $10$ digits.

Since there are eight positions, there are $\binom{8}{2}$ ways to choose the positions of the digits. Each of these two positions can be filled with a digit in $10$ ways, giving us the factor $10^2$. Each of the remaining six positions can be filled with a letter in $21$ ways, giving us the factor $21^6$. Hence, the number of favorable cases is $$\binom{8}{2}10^221^6$$

What are you doing wrong?

The number $\binom{10}{2}$ counts the number of ways of selecting two of the ten digits. Therefore, you have selected two different digits, but digits may be repeated. Similarly, $\binom{21}{6}$ counts the number of ways of selecting six different letters, but letters may be repeated. You also did not choose the positions of the letters.