# Counting Problem (4 Digit Code) - Equality

I have that the number of 4 digit codes (each can be 0-9) is $$10^4$$.

I know that the number of 4 digit codes with no repeats is $$P(10,4)$$.

I figured that (the total number of 4 digit codes) - (4 digit codes with no repeats) should equal

(4 digit codes with 3 repeats) : 10

$$+$$

(4 digit codes with 2 repeats) : $${4\choose 3} \cdot 10 \cdot 9 = 360$$

$$+$$

(4 digit codes with 1 repeats) : $${4\choose 2} \cdot 10 \cdot 9 \cdot 8= 4320$$

but

$$4690 \neq 4960$$

You missed $$\overline{AABB},\overline{ABAB}$$, $$\overline{ABBA}$$ etc which contains $${4\choose 2} \cdot 10 \cdot 9 \cdot\frac{1}{2}=270$$ cases, and $$4690 + 270 = 4960$$.