Question A lock combination code is made up of $4$ numbers ($0-9$). Each number can occur at most twice, e.g. $4764$ would be allowed but not $4464$ as the number $4$ has occurred more than $2$ times.Therefore, how many possible combination codes are there?
I know that there are $10,000$ possible combinations if repetitions are allowed. However I'm unsure as to how to answer the question. Any help is greatly appreciated, thanks!
Here is a possible solution using the Principle of Inclusion/Exclusion:
$\textbf{Case 1}$ (digit is repeated $3$ times):
Choose the repeated digit in $10 \choose 1$ ways.
Choose the remaining digit in $9 \choose 1$ ways.
Order the digits in $\frac{4!}{3!} = 4$ ways.
$\textbf{Case 2}$ (digit is repeated $4$ times):
Choose the repeated digit in $10 \choose 1$ ways.
Order the digits in $\frac{4!}{4!} = 1$ way.
So the number of combinations that don't satisfy your constraint is $(10 * 9 * 4) + (10 * 1) = 370$. Subtracting these from the $10,000$ total combinations yields $\textbf{9,630}$ ways.