# Basic Counting Method - Number of Arrangements

For a $4$-digit string, where each digit can be from $\{0,1,..,9\}$, what is the probability that the number contains exactly two different digits (e.g. $3555$)?

The answer is $\binom{10}{2}\cdot (2^4-2)/10^4$. I couldn't get anything close to that answer. I'm guessing I'm under-counting, but I don't see what I'm missing.

-
The answer here suggests you must have 1 digit of one kind and 3 of another. While the problem suggests that two of each kind is acceptable (Such as 5566). See my answer below for that case. – Guest 86 Jan 21 '13 at 16:07

There are $\binom{10}2$ ways to choose the two digits. The smaller digit can appear $1,2$, or $3$ times. There are $\binom41$ ways in which it can appear once, $\binom42$ ways in which it can appear twice, and $\binom43$ ways in which it can appear three times, for a total of $\binom41+\binom42+\binom43=14=2^4-2$ ways. (The $2^4-2$ can also be obtained directly by starting with the $2^4$ strings of length $4$ and eliminating the two that have one digit repeated four times.) The total number of acceptable strings is therefore $\binom{10}2(2^4-2)$, as claimed.

-

To create a four-digit string with two different digits, you first need to pick two digits, and then decide how to choose each of your $4$ digits. The number of ways to choose two digits is exactly $${10 \choose 2}.$$ Now, to choose which digits to put on each of the four positions, you basically have two options for each digit, i.e., $2^4$ options in total. But then you are also counting solutions like $1111$ and $7777$, which only contain one digit. Subtract those $2$ to get $${10 \choose 2} \cdot (2^4 - 2).$$ To get the probability of getting one of these sequences, you then divide this number by the total number of four-digit strings, which is $10^4$. So indeed, the answer is $$\frac{{10 \choose 2} \cdot (2^4 - 2)}{10^4}.$$

-

First of all picking two digits is the (10 over 2) as for the first you have 10 options and the second the remaining 9 (And because picking 5,6 or 6,5 is the same).

Now there are two ways to arrange 2 different digits in 4 locations: Either 3,1 or 2,2.

If we're looking at the 3,1 arrangement, pick one of the 2 digits you chose and chose a place out of the 4 to put it.

If we're looking at the 2,2 arrangement, you can pick the smaller of the two digits and pick 2 places out of the 4 to put it in (4 * 3 as you have 4 places to pick for the first copy and another place out of the remaining three). The other digit will fill the remaining two places.

In other words, (10 over 2)*(2*4 + 1*4*3).

The amount of ways to write a 4 digit number out of 10 digits with repetitions is 10^4 as for every place of the 4 you can pick any of the 10 digits.

Resulting in a probability of (10 over 2)*(2*4 + 1*4*3)/10^4.

P.S Both your solution and the other two ignore the fact that 3344 fits the description.

P.P.S In the second case when we said pick the smaller, I didn't bother to explain this in place: If you picked either of the two, you might end up with numbers like 5566 both when picking 5,6 and 6,5 due to symmetry and should therefore divide the result by two. The requirement of picking the smaller one breaks the symmetry so that when 5,6 are present only a single pick is possible, avoiding the double count.

-