How many five-digit numbers can be made from the digits $0, 1, 2, 3, 4$, provided that each digit can be repeated twice

algebra-precalculuscombinationscombinatorics

The 10,000th place can be filled in $4$ different ways, the 1000th place can be filled in $5$ different ways, the 100th place can be filled in $4$ different ways, seeing the double repetition of numerical values, and the 10th and 1st places must be filled $(5-2)=3$ different ways each. Thus, the total number of possible such 5-digit numbers is $4 \cdot 5 \cdot 4 \cdot 3 \cdot 3 = 720$.
However, i found the following solution:
$$1) 1\cdot5!/1=120$$
$$2) 5\cdot5!/2=300$$
$$3) 10\cdot5!/4=300$$
$1)$ understandable. The number of all possible choices with zero in any position.
$1) 2)$ already incomprehensible. In theory, you need to calculate how many numbers there will be so that there is no zero in front. After all, such numbers are invalid. And somehow calculate, the number of options with repeating numbers $2$ times. Could you explain this to me?

Best Answer

If leading zero is allowed, the count of numbers with given constraints is $2220$ as you mentioned in the comments. But if we only consider actual five digit numbers, you can either subtract all numbers with leading zero meeting other constraints from $2220$. Here is another way to go about it -

a) The most significant digit does not repeat -

  • $4$ ways to choose the most significant digit

i) two digits repeat

  • $\displaystyle {4\choose 2}$ ways to choose digits to repeat and $\dfrac{4!}{2! \ 2!}$ ways to permute them.

ii) one digit repeats

  • $4$ ways to choose the digit to repeat and $3$ ways to choose $2$ remaining digits and permute them in $\dfrac{4!}{2!}$.

iii) No repetition

  • All digits must be chosen and they can be permuted in $4!$ ways.

b) The most significant digit repeats -

  • again, $4$ ways to choose the most significant digit

i) two digits repeat

  • we choose another digit to repeat in $4$ ways and another digit from remaining $3$ digits in $3$ ways and then permute them in $\dfrac{4!}{2!}$ ways.

ii) only one digit repeats

  • we choose three digits from remaining $4$ digits in $4$ ways and permute them in $4!$ ways.

So total number of ways =

$ \displaystyle 4 \cdot \left[{4\choose 2} \frac{4!}{2! \; 2!} + 4 \cdot 3 \cdot \frac{4!}{2!} + 4! + 4 \cdot 3 \cdot \frac{4!}{2!} + 4 \cdot 4!\right] = 1776$