# How to calculate number of favourable cases for the following problem

How to find the total cases where a four digit number has two like digits,three like digits, two pairs of like digits, four like digits etc...

-
Have you no thoughts of your own on how to do this? – Gerry Myerson Aug 31 '12 at 12:09
Four like digits is not hard, though the answer depends upon whether you allow 0000. – Ross Millikan Aug 31 '12 at 13:05

I will assume that the four-digit numbers start with $1000$. If you allow things like $0075$ as four-digit numbers, then the calculations become substantially smoother.

I am sure that you can answer some of the questions easily. For example, one can list and count the "four like digit" numbers. They are $1111$, $2222$, and so on up to $9999$, a total of $9$.

Probably the next easiest to count is the "two pairs" case. The first digit can be chosen in $9$ ways. Suppose that for example we choose the first digit to be $4$. There are $3$ ways to decide where the other $4$ will go. And once we have decided that, there are $9$ choices for what digit the remaining two "holes" will be filled by. So we end up with $(9)(3)(9)$ "two pairs" numbers.

We now count the "one pair" numbers. It is maybe easiest to break up the work into two cases: (i) The pair involves the first digit and (ii) The pair does not involve the first digit.

For (i), the first digit can be chosen in $9$ ways. the location where the first digit is matched can then be chosen in $3$ ways. Once we have done that, we have two empty slots left. We can fill the leftmost one in $9$ ways. For each of these, we can fill the remaining empty slot in $8$ ways, for a total of $(9)(3)(9)(8)$. For (ii), the first digit can be chosen in $9$ ways. For each such choice, the slot that will not hold the pair can be chosen in $3$ ways, and the number that fills that slot can then be chosen in $9$ ways. Once we have done that, the number we have two of can be chosen in $8$ ways, for a total of $(9)(3)(9)(8)$. Thus the number of "one pair" numbers is $(9)(3)(9)(8)+(9)(3)(9)(8)$.

Finally, we deal with the "one triple" numbers. The triple could (i) Not involve the first digit or (ii) Involve the first digit. For (i), the first digit can be chosen in $9$ ways, and then the digit we have $3$ of can be chosen in $9$ ways, for a total of $(9)(9)$. For (ii), the first digit can be chosen in $9$ ways. For each such choice, the location of the odd digit can be chosen in $3$ ways, and then the odd digit can be chosen in $9$ ways, for a total of $(9)(3)(9)$. thus the number of "one triple" numbers is $(9)(9)+(9)(3)(9)$.

Remark: There are many other ways to organize the calculation. One clever thing to do would be to temporarily allow $0$ as an initial digit: then the calculations are smoother. After doing the computations, we subtract the forbidden cases. I would urge you to experiment with ways of counting. The numbers I have obtained can then serve as a check.

-
If the two pairs are distinct, then your second paragraph should read "And once we have decided that, there are 8 choices..." – Byron Schmuland Aug 31 '12 at 15:37
@ByronSchmuland: I think it is $9$. Whatever choice we made for the first digit, there are $9$ choices of who will make up the other pair, since now $0$ is allowed. – André Nicolas Aug 31 '12 at 15:42
Oh I see. The OP is not very clear on whether we wants to include four digit numbers like $0123$. You've decided to leave them out. – Byron Schmuland Aug 31 '12 at 15:45
@ByronSchmuland: Thought I would go with the everyday meaning of four-digit number. – André Nicolas Aug 31 '12 at 15:53

For this kind of counting argument, I like to use multinomial coefficients to keep things straight. Suppose I want to count the number of ordered strings of length four, taken from a set of ten digits, showing two different pairs; like this $0101$, $6446$, etc. Note that I am not going with the everyday meaning of four-digit number.

I first count the number of ways to select the digits, then multiply by the number of ways to arrange the digits.

$$\begin{array}{cc} \text{Choose digits} & \text{Arrange them}\\[5pt] {10\choose 8,0,2}&{4\choose 2,2} \end{array}$$

This works out to $270$.

How do you read those multinomial coefficients? The first one gives the frequencies of the ten digits: there will be 8 digits that do not appear, 0 digits that appear exactly once, and 2 digits that appear twice. For the second one, under the four we have the pattern 2,2; that is, two pairs.

You can change the numbers to solve similar problems. Let's try 3 pairs in a string of length 6: $${10\choose 7,0,3}\times {6\choose 2,2,2}=10800.$$
How about one triple, one pair, and one single in a string of length 6: $${10\choose 7,1,1,1}\times{6\choose 1,2,3}=43200.$$

One last example: If you roll a die ten times, how many outcomes have one quintuple, two pairs, and a single? $${6\choose 2,1,2,0,0,1}\times {10\choose 1,2,2,5}=1360800.$$

-
Why do you include $0's$ in the first terms of the expressions ? – true blue anil Dec 2 '15 at 4:48
@trueblueanil The zeros are not really needed, of course, but they help in the sense that, for example, in $2,1,2,0,0,1$ the index of each number gives the size of group. – Byron Schmuland Dec 2 '15 at 12:36