# What is the total number of combinations such that a $6$-digit pin contains exactly $4$ distinct digits?

Including $$0$$ as the leading digit e.g. $$011232$$

The solution is $$C(10, 4) \cdot \left[C(4, 2) \cdot \frac{6!}{(2!)^2} + C(4, 1) \cdot \frac{6!}{3!}\right]$$ I understand what it represents; taking into account the outcome where $$1$$ digit repeats thrice and the outcome where $$2$$ digits repeat twice.

However, I don't understand how it represents these outcomes where $$2$$ digits are repeated twice. Why do we multiply $$C(4, 2)$$ by $$6!/(2!)^2$$?

E.g. the outcome were $$1$$ digit is repeated thrice makes sense to me; if the digits are thought of _ _ _ _ _ _ then $$6!/3!$$ just represents the number of ways I can fill the non-repeating digits in the placeholders. Nothing else matters here since the other placeholders are filled by the same number so you can't form more permutations.

I'm looking for a similar explanation for the the other scenario.

• Choose the four digits in $\binom{10}{4}$ ways. Then choose the two digits (say $a$ and $b$) that get repeated in $\binom{4}{2}$ ways. So we have our collection of six digits. There are $6!$ ways to order six digits. But we have to divide by $2!$ because the two digits $a$ are indistinguishable. Similarly divide by $2!$ again for the two digits $b$. This explains the factor of $(6!)/(2!)^2$. BTW the expression you wrote isn't a probability, rather the number of possible PINs. Dec 18, 2021 at 19:23
• @jlammy Thanks, that cleared up all confusion. Dec 18, 2021 at 19:28
• Welcome to MathSE. This tutorial explains how to typeset mathematics on this site. Dec 19, 2021 at 10:33
• @jlammy Please turn your comment into an answer so that the question can be closed. Dec 19, 2021 at 10:37

Choose the four digits in $$\binom{10}{4}$$ ways. Then choose the two digits (say $$a$$ and $$b$$) that get repeated in $$\binom{4}{2}$$ ways. So we have our collection of six digits. There are $$6!$$ ways to order six digits. But we have to divide by $$2!$$ because the two digits $$a$$ are indistinguishable. Similarly divide by $$2!$$ again for the two digits $$b$$. This explains the factor of $$(6!)/(2!)^2$$.