Count of number of $3$-digit strings with at least two of $0,1,2$.

combinatorics

Find the count of $3$-digit strings with at least two of $0,1,2$.

Well I am getting $432$ as the answer, which I think is way too much.
For starters, I considered that one number of $\{0,1,2\}$ could take any place so $3 \times 3$. Then any other number (previous number included) would take $3 \cdot 2$ so total rn is $3 \times 3 \times 3 \times 2$, now the last place can be filled by any of the $9$ digit so $\times 9$.

After reducing the repeated numbers ($9 \times 3 \times 2$), which according to me will all be palindromes with these numbers, I got my result.

Looks like I need help here. If I did anything wrong, I'd be happy to hear your comments.

Best Answer

There are $1000$ possible strings with no constraints whatsoever. Of those, $7^3=343$ use none of the digits $\{0, 1, 2 \}$.

To count the strings that have an entry from $\{0, 1, 2 \}$ in exactly one position, note that we have $3$ choices of that position, $3$ choices from among $\{ 0, 1, 2 \}$ to fill that position, and $7^2=49$ choices to fill the remaining positions, for a total of $9 \cdot 49=441$ additional "bad" strings.

Thus, there are $1000-(343+441)=216$ "good" strings.

Edit: As noted by fleablood in an answer and by JMoravitz in a comment, you can use the same method of analysis to count the "good" strings directly. There are $3^3=27$ strings that fill all three positions from the set $\{0, 1, 2\}$.

To count the strings that have an entry from $\{4, 5, 6, 7, 8, 9, 0 \}$ in exactly one position (and therefore entries from $\{ 1, 2, 3 \}$ in exactly two positions), note that we have $3$ choices of that position, $7$ choices from among $\{ 4, 5, 6, 7, 8, 9, 0 \}$ to fill that position, and $3^2=9$ choices to fill the remaining positions for a total of $3 \cdot 7 \cdot 9 =189$ additional "good" strings.

Thus, there are $27+189 = 216$ good strings.