# Creating digit sequences that can't begin with $0$, but one digit must repeat exactly once.

Is my reasoning OK here? My doubt is mainly on the second part of this problem.

How many 6-digit sequences are there with exactly 1 digit repeated?

So, we have 6 slots:

$$\_ \ \ \_ \ \ \_ \ \ \_ \ \ \_ \ \ \_$$

First, we should put the digit that is supposed to be repeated. There are

$${6 \choose 2}$$

Ways to put it (and its replica) in the sequence. So now we are left with four slots to fill. The digits we put in the slots cannot repeat, and the order does matter.

From the $10$ digits we could pick, we only have $9$ now because one of them is already used.

Given the four slots

$$\_ \ \ \_ \ \ \_ \ \ \_$$

We need to permutate $9$ digits. So

$$\frac{9!}{(9-4)!}$$

$${6 \choose 2} \cdot \frac{9!}{(9-4)!}$$

What if such sequence cannot start with $0$?

$$\_ \ \ \_ \ \ \_ \ \ \_ \ \ \_ \ \ \_$$

First, let's put some non-zero digit $X$ of the $9$ ones we got available:

$$X \ \ \_ \ \ \_ \ \ \_ \ \ \_ \ \ \_$$

There are $9$ ways to choose such digit.

Now, two things happen:

• The chosen digit $X$ happens to be the one that is repeated.
• We must choose one of the five spots left to hold the replica. There are $\color{red}{5}$ ways to do that.
• Now that we chose the spot to hold the replica, there are four spots left to hold whatever other digits. Given four spots and $9$ digits free, we permutate: $\color{red}{\frac{9!}{(9-4)!}}$
• The chosen digit $X$ is unique in the entire sequence.
• So the digit that is repeated must still be chosen. We can use the same formula as the one in the previous question, but with a few modifications: $\color{blue}{{5 \choose 2} \cdot \frac{8!}{(8-3)!}}$

$$9\cdot\left(\color{red}{5 \cdot \frac{9!}{(9-4)!}} + \color{blue}{{5 \choose 2} \cdot \frac{8!}{(8-3)!}}\right)$$

• You might be expected to read "exactly 1 digit repeated" to say there is exactly one pair of neighboring digits that match. This leads to a different answer, but which is the correct reading is not a mathematical question. I agree with your answers given your reading. Jun 2, 2014 at 3:03
• @RossMillikan: I see. So if the question meant that the two repeated digit must be together, I would apply Bananarama's answer? Jun 2, 2014 at 3:07
• No, you would have only $5$ choices for the location of the leftmost matching digit instead of $6 \choose 2$ for the location of the matching digits. Then you have the same choices to fill in the rest of the blanks as you found. But in your answer you missed the $10$ choices of the repeated digit. You mention it, but it is not in your formulas. Jun 2, 2014 at 3:17
• @RossMillikan Why is my answer wrong? Jun 2, 2014 at 3:45
• You have $10 {6 \choose 2}$ for the repeated digits. Besides choosing the positions, you need to choose the digit. Your answer is missing the factor $10$ Jun 2, 2014 at 13:42

You can pick the pair of digits which are to be repeated in $\binom{6}{2}$ ways. This will separate the spaces for the digits into $5$ sections(four sections of one number and one section of two numbers), now you need to pick which number each section will have, this can be done in $9\frac{9!}{(9-4)!}$ ways(since the section containing the left-most digit can't be zero), after selecting both of these things you have determined the number completely. Thus the answer is simply $9\binom{6}{2}\frac{9!}{(9-4)!}=408240$
Regarding the other interpretation of the problem: where there is exactly one pair of consecutive numbers that is the same: This is the same is the same as 5 multiplied by the number of 5-digit numbers not starting in $0$ that don't contain consecutive equal digits(since once we have a sequence of with no consecutive equal digits we can choose one of those digits and add a digit equal to that one to its right, to obtain a 6 digit number containing exactly one pair of consecutive equal digits.). How many of these are there? we have 9 choices for the left-most digit digit, 9 choices for the digit to its right and in general 9 choices for each digit. So there are $5\cdot9^5=295245$