# How many 4 digit numbers can be made with exactly 2 different digits

I need to find how many four digit numbers can be made using exactly 2 different digits. ALL DIGITS FROM 1 TO 9 CAN BE USED. NOT JUST 1 AND 0

-
Are leading zeros allowed, as in 0220? – Henry Nov 20 '12 at 12:21
yes zeroes can be the starting digit – chndn Nov 20 '12 at 12:26
I think you mean all digits from 0 (not $1$) to $9$. And you don't need to shout. – Marc van Leeuwen Nov 20 '12 at 13:13
You should make some effort yourself. Having people feed you answers here before you've even engaged your brain will not help you learn anything. – Rhys Nov 20 '12 at 13:56

There are $\,2^4=16\,$ different ways to arrange two objects in patterns of $\,4\,$, from which you have to substract the patterns that contain all the elements equal, and there are $\,\binom{10}{2}=45\,$ different ways to choose two different objects out of $\,10\,$, so...

-
All DIGITS FROM 1 TO 9 IS ALLOWED. NOT JUST 0 AND 1 – chndn Nov 20 '12 at 12:59
You meant "digits from 0 to 9"? Never mind: if it is only 1 to 9 then put 9 instead of 10 in my answer and change accordingly. The rest remains the same. – DonAntonio Nov 20 '12 at 13:03

These are 2^4 it's same as having 4 bits represented by 0 and 1 if i understand you correctly.

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 .... 1111

2^4 = 16

-
The numbers should have exactly 2 different digits – chndn Nov 20 '12 at 12:28
no less no more – chndn Nov 20 '12 at 12:29
when 0000 and 1111 is not allowed then (2^4)-2 = 14 ? – r4d1um Nov 20 '12 at 12:31

Hint:

• fixing a pair $(n,m)$ of digits, count the amuont of $4$-digit numbers you can make with them, using each of them at least one.
• Count the number of of choices for $(n,m)$, and multiply by that. Should the order of the pair be taken into consideration?
-
All DIGITS FROM 1 TO 9 IS ALLOWED. NOT JUST 0 AND 1 – chndn Nov 20 '12 at 12:55
@chndn: I think you mean all digits from 0 (not $1$) to $9$. And you did not need to post the comment here, as I was clearly aware of that. Indeed you only needed to post the comment to the answer by r4d1um (who apparently thinks in binary), which is the only place you dit not do so. And you don't need to shout. – Marc van Leeuwen Nov 20 '12 at 13:13

from the numbers $0$ to $9$, $2$ different numbers can be selected in ${10\choose2}$ ways. Of these, $9$ are $01$,$02$,$03$,$04$,$05$,$06$,$07$,$08$,$09$. ${10\choose2}=45.$ $45-9=36$ the groups are $$12,13,14,15,16,17,18,19,23,24,25,26,27,28,29,34,35,36,37,38,39,45,46,47,48,49,56,57,58,59,67,68,69,78,79,89$$ (different numbers).

Taking one group at a time, for example,$12$, we get $2^4$ numbers. therefore, for $36$ groups we get $36*(2^4)$ numbers. but, among these numbers there are numbers like $$1111,2222,3333,4444,5555,6666,7777,8888,9999$$ Each of these repeats $8$ times. So there are $8*9=72$ numbers with same digits.

Removing these, $36*(2^4)-72$ gives the number of numbers with two digits, not all digits same.

Now taking groups $01,02,03,04,05,06,07,08,09.$

Each group gives $2*2*2*1 =8$ numbers. In the multiplication I have put $1$ because digit in thousand's place cannot be $0$.

Among these numbers there are $1111,2222,3333,4444,5555,6666,7777,8888,9999$

So the final answer is $36*(2^4)-72+8.$

-