# Picking Numbers for a Digit

How many three digits numbers are out there with two digits the same and the other different?

If I imagine I have three slots. __ __ __. The first slot is the only one with a restriction. The range of digits can be $[1,9]$ while the 2nd and 3rd can take any digit value from $[0,9]$ Overall I have 900 ways.

Since I am really picking two numbers (one of which will be the pair and the other the single digit. I can do ${10 \choose 1}{9 \choose 1}$. But the problem I am having is don't I have to take into account which I pick first, the two digit pair or the single digit? And once I do pick the digit for the pair and the digit for the single number, how do I specify that "hey, this number is for the pair, this number is for the single".

• First, how many three digit numbers are there? Then, out of the numbers $[1,100]$, how many have double-digits? It seems to me that $900$ is quite high... – abiessu Oct 6 '13 at 15:38
• 900 is correct. 9*10*10 – jessica Oct 6 '13 at 15:40
• $900$ is the number of three digit numbers. I thought you were saying that was the number of double-digit numbers. So out of the numbers $x00-x99$ how many are double-digit numbers? – abiessu Oct 6 '13 at 15:49

900 is too high. I'll try to show you how to calculate it by looking at different orders of the calculation. But first let's try to understand why $900$ is off.

The problem with $9 \cdot 10 \cdot 10$ is that you are performing a calculation without considering the effect of the choice you make for each digit. If you had 9 choices for the first digit, 10 choices for the next, and 10 choices for the next, you could do that in $9 \cdot 10 \cdot 10 = 900$ ways. Consider the case in which you chose the single digit in the hundreds place, there are 9 choices for it. Say you select a 3 for the hundreds place. You would not then have 10 choices for the doubled digit, you would have $10-1 = 9$ because 3 cannot be the doubled-digit and the single digit. Ok, so now you choose the number in the tens place you have 9 options. You choose to use the $4$ from your 9 remaining options. So in choosing the first two numbers you had 9 options and then 9 options. But now that you have decided those two and which is repeating you have only 1 option for the final digit, it must be a 4. So your choices were really 9 options, 9 options, 1 option. The $9 \times 10 \times 10$ assumes that a choice for one digit does not diminish the range of choices for a later digit.

Below I'll show a few ways you could solve the problem.

## Choosing the double-digit first

If the double digit includes the first digit then you have ${9 \choose 1}$ choices for the double digit and ${10 -1 \choose 1}$ choices for the remaining digit since one of the digits was chosen for the doubled digit and we don't want to count combinations in which all three digits are the same. So ${9 \choose 1} \cdot {9 \choose 1} = 81$ ways this can happen. However, the double digit can be either in the second or third digit, so we have 2 choices of where to place it so ${9 \choose 1} \cdot {9 \choose 1} \cdot 2 = 162$.

If the single digit is in the hundreds place there are ${9 \choose 1}$ ways it can be chosen. Once selected that leaves ${10-1 \choose 1}$ ways to select the double digit in the tens/ones place. There is only one way to place the double digits into the tens/ones so we don't have to double the result. We have ${9 \choose 1} \cdot {9 \choose 1} = 81$ ways this can be done.

Combining these results we have 243 numbers with two digits the same and one different.

## Choosing the single-digit first with a twist

Let the single digit [1-9] fall in the hundreds place there are ${9 \choose 1}$ choices. With this single-digit position, the doubled digit may fall in the range [0-9], so we have ${10 -1 \choose 1}$ choices. Therefore with the single-digit in the hundreds there are ${9 \choose 1} \cdot {9 \choose 1} = 81$ numbers.

Now let the single digit be in the tens or ones place. Here's the twist, in these cases if we consider choosing the single digit first we have 10 choices, but depending on which choice we make we have to consider the choices for the hundred's place differently. So for simplicity, let's choose the double-digit first in these cases there are ${9 \choose 1}$ choices for the double digit, and ${10 - 1 \choose 1}$ choices for the single digit as well as ${2 \choose 1}$ locations for the single digit. So, ${9 \choose 1} \cdot {2 \choose 1} \cdot {10 -1 \choose 1} = 162$ numbers. Again there are $81 + 162 = 243$ such numbers.

## Really actually choosing the single-digit first

I've already looked at what happens if you choose the single-digit in the hundred's place: ${9 \choose 1} \cdot {10 - 1 \choose 1} = 81$ such numbers.

Now, if we are truly set on calculating the outcomes and choosing the single digit first, it's easiest to consider two non-overlapping cases. Case 1: the single digit is in the range [1-9] and case 2: the single digit is a 0.

If the single-digit is in the range [1,9], then there are ${2 \choose 1}$ positions it can occupy combined with ${9 -1 \choose 1}$ choices for the double-digit we have ${9 \choose 1} \cdot {2 \choose 1} \cdot {9-1 \choose 1} = 144$ numbers. If the single digit is a zero, then there are ${9 \choose 1}$ choices for the double digit so we have ${1 \choose 1} \cdot {2 \choose 1} \cdot {9 \choose 1} = 18$ such numbers.

Again there are $18 + 144 + 81 = 243$ such numbers.

One way to calculate it and reason about it is like this: first, pick the first digit f (9 possibilities). Then, pick the "other" digit o, not equal to the first digit (10 - 1 possibilities). We then have three situations: ffo, fof, foo. Total number of combinations: $9 \times 9 \times 3 = 243$.

One way to calculate, which can also work for generalizations of the problem, is to calculate how many ways all digits are distinct. This is $9 \cdot 9 \cdot 8$, by counting choices for each digit starting from the first. So $900 - 9 \cdot 9 \cdot8$ gives the number of ways at least two digits are the same. But this also includes the $9$ cases when all three digits are the same. So you need to subtract this too, giving $900 - 9 \cdot 9 \cdot 8 - 9 = 243$ as the answer.

Choose a digit in $[0,9]$ and a slot to place it. Then choose a different digit and place two copies of it into the two other slots. By symmetry one tenth of the numbers so produced will begin with a $0$ and have to be excluded. Therefore the total number $N$ of admissible three-digit numbers is given by $$N=10\cdot 3\cdot 9\cdot{9\over10}=243\ .$$