[Math] Permutation and Combination for 6-digit numbers contain exactly 4 different digits

combinationspermutations

I found a question online.

How many 6-digit numbers contain exactly 4 different digits ?

My Solution is :
There are 6 digits and 4 needs to be unique so either 2 digits can be same or 3 can be same.

Ans:
Solution 1: (9C1*9C1*8C1*7C1*(4C1*3C1) * 6!/2!*2! + 9C1*9C1*8C1*7C1*(4C1*1C1)* 6!/3!).
This should be the solution. But it gives wrong answer

But there is another solution mentioned which gives the correct answer.

Solution 2: This is the solution given online.
C(10, 4)* [C(4, 2)* 6!/(2!)2 + C(4, 1)* 6!/3!] =10*9*8*7*5*13
Removing the cases starting with zero

= 9*9*8*7*5*13 = 294840 .

Both these approaches gives 2 different answer, now which one to use, I select 2 digits from 4 numbers should i use 4C2 or 4C1*3C1 , similarly selecting 4 digits from 10 number, is it 10C4(replace 10 with 9 in the expression later on) or is it 9C1*9C1*8C1*7C1.

When to use which.
Please help, really confused.

Best Answer

Exactly four different on 6 means that there are some repetitions. Maybe one digit repeated 3 times or maybe 2 repeated two times, example: 111235, 224456. So you want to know these two type of variations and sum them.

There are named variations with repetition and you calculate them in two steps:

1) Think the different digits as groups so a number as AABCDA have 4 different groups: A, B, C and D. Over these 4 groups calculate the number of permutations with repetition with the multinomial coefficient

$$PR_{n}^{k_1,k_2,...,k_n}=\binom{n}{k_1,k_2,...,k_n}=\frac{n!}{k_1!k_2!\cdots k_n!};\ n=k_1+k_2+...+k_n$$

In you case you have two different setups as said above so

$$PR_1=\binom{6}{2,2,1,1}=\frac{2\cdot3\cdot4\cdot5\cdot6}{2\cdot2}=180\\ PR_2=\binom{6}{3,1,1,1}=\frac{2\cdot3\cdot4\cdot5\cdot6}{2\cdot3}=120$$

2) Now for each type of permutation you must calculate the number of variations because A, B, C or D could be any digit between 0 and 9. There are variations of 10 elements over 4 positions, so

$$V_n^k=(n)_k=n(n-1)(n-2)\cdots(n-k+1)\\ V=(10)_4=10\cdot9\cdot8\cdot7=5040$$

3) The total of different number for each setup will be $\sum_{i}PR_i\cdot V$ but we need to discount the combinations that start with zero(s) that are a 10% of the total because exist the same probability for any number in any position and they are 10 different numbers, so the probability that the first digit will be a zero is $\frac{1}{10}$.

And the amount $PR_1$ must be divided by two because the two groups of two elements will repeat the same configuration twice, i.e., we have (by example) the configuration of permutations AABBCD where A, B, C and D take values from 0 to 9 (that is counted on the variations) but there is a symmetric permutation as BBAACD that can repeat the same numbers. The same happen for C and D so we must divide again by two to fix the duplicities. These numbers are the permutations of each type of indistinguishable multiplicity, i.e, $2!=2$.

In a similar way happen with the second setup $PR_2$ with B, C and D. So we need to divide between the number of permutations of indistinguishable multiplicities that is $3!=6$ (and $1!=1$).

So the total of cases will be

$$C=\left(PR_1\frac{1}{4}+PR_2\frac{1}{6}\right)V\cdot\frac{9}{10}=(45+20)81\cdot 56=294840$$