Distinct digits in a combination of 6 digits

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

My approach is:
For any 3 digis same and the remaining 3 different(aaabcd)

4*9*8*7*6

For any 2 duplicate digits(aabb) and the remaining 2 different (aabbcd)

9*8*7*6*3

But I don’t know how to add cases where there can be 0’s can be as any digit but not the initial ones.

Can someone please help me if there is any simpler approach?

Solutions Collecting From Web of "Distinct digits in a combination of 6 digits"

Since the answers in the linked question, I still feel are lacking, here I hope to answer in a more colorful way which avoids “division by symmetry” arguments.

Begin as you have by breaking it into cases: either a single number appears three times and three other numbers appear once or two numbers appear twice each and two other numbers appear once each.

Throughout all of the following explanations, let us imagine six slots in which we will fill balls of various colors.

Case 1: Let us imagine we have three blue balls and three red balls. The locations occupied by the blue balls will be correspond to the number which appears three times. Each red ball space will be one of the single appearing numbers.

  • Pick which spaces are occupied by the three blue balls out of the six spaces. There are $\binom{6}{3} = \frac{6!}{3!3!}=20$ ways to accomplish this step.
  • From left to right, take a ball and assign a number to it. If blue, then the number assigned is set to all blue balls, not just the one. If red, then the number is assigned only to itself. In all cases, the number cannot match another selected during this process. Assuming that zero is not allowed to lead (implied by the problem calling it a NUMBER instead of a STRING), there are $9\cdot 9\cdot 8\cdot 7$ ways to accomplish this step.

Hence there are $20\cdot 9\cdot 9\cdot 8\cdot 7$ arrangements in this case.


Case 2: Here, we have two light blue balls, two dark blue balls, and two red balls. The locations of the red balls will correspond to those digits which appear only once each. The blue balls will correspond to the digits which are repeated, however since we don’t actually care which one of the “pairs” was first (dark blue or light blue) in order to avoid over-counting we will forcibly place a lightblue ball in the left-most not-red spot.

  • Pick which spaces are occupied by the two red balls out of the six spaces. There are $\binom{6}{2} = 15$ ways to accomplish this step.
  • Forcibly place a light-blue ball in the left-most not red space. $1$ way to accomplish this step.
  • Out of the remaining three spaces, pick which receives the remaining light-blue ball. The dark-blue balls will take the remaining spaces. $3$ ways to accomplish this step.
  • From left to right, assign a number to the ball. If the ball is light-blue, then assign that number to the other light-blue as well. If dark-blue, assign it to the other dark-blue as well. Again, assuming leading zeroes is not allowed, there are $9\cdot 9\cdot 8\cdot 7$ ways to accomplish this step.

Hence there are $15\cdot 3\cdot 9\cdot 9\cdot 8\cdot 7$ arrangements.

This gives a total of $9\cdot 9\cdot 8\cdot 7\cdot (20+3\cdot 15)=294840$ arrangements.

Firstly, let us forget about leading zeroes.

A simple way of solving such problems is looking at patterns, how many numerals of each kind,
and using the formula [Choose numerals for placing] $\times\;$[Permute them]

Here there are only two possible patterns,

$3-1-1-1 \;of\;a\;kind:\;\left[\binom{10}1\binom93 \right] \times[ \frac{6!}{3!}] =100,800$

$2-2-1-1\;of\;a\;kind:\;\left[\binom{10}2\binom82 \right] \times [\frac{6!}{2!2!}] =226,800$

These add up to $327,600$, and since $\frac1{10}$ of these must start with $0$,

we get the final answer as $0.9\times327,600 = 294,840$