[Math] How many strings of five decimal digits contain exactly three distinct digits

combinationscombinatoricsdiscrete mathematics

Here is my thought process so far:

There are $10$ options for the first number, $9$ for the second, and $8$ for the third. According to this current structure, the fourth and fifth digits would have to be one or two of the three already selected digits in some order. If the first three digits were $1, 2, 3$, then the possible permutations for the fourth and fifth spots are: $11, 22, 33, 12, 21, 13, 31, 23,$ and $32$.

So the answer so far would be $(10 \times 9 \times 8) \times (9) $

Therefore: Per three distinct digits, there are already $9$ options for a string. Additionally, the fourth and fifth spots which contain $1$ or more of the distinct digits for the first repeated occurrence don't have to be at the end. I thought that I should multiply the present answer by $(5$ choose $3) = 10$ to account for this additional variation in order, but I can tell that there must be some number of strings which are counted twice by this method, so

$(10 \times 9 \times 8) \times (9) \times (10) = 64800$ is probably too great. Any suggestions? Thank you

Best Answer

I think you're on the right track, but I wouldn't recommend fixing the first 3 spots to be distinct numbers as you do. For example, the number $11231$ satisfies the condition of being a 5-digit number with exactly $3$ different digits, but doesn't have the first $3$ digits distinct.

I noticed that you have $10 * 9 * 8 = 720$ ways to pick your first $3$ digits to use in order. Instead, I would suggest that you just find the total number of combinations of $3$ digits you could use in making your string, which is $10$ choose $3$, or $120$. Given this, the next step would be to split the problem into cases. As you seem to have noticed, you can either have $2$ of the digits be used twice, or $1$ of the digits be used thrice.

Let's consider case $1$, which is that you have $2$ digits used twice. There's $3$ ways to choose which of the $3$ digits to use twice, and then a total of $\frac{5!}{2! * 2!} = 30$ ways to arrange the digits afterwards, giving us a total of $120 * 3 * 30 = 10800$ possible arrangements.

Now, try to calculate the other case by yourself and see if you're able to arrive at the answer.

Related Question