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)!}$$
The answer would be
$${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)!}}$
The final answer would be
$$9\cdot\left(\color{red}{5 \cdot \frac{9!}{(9-4)!}} + \color{blue}{{5 \choose 2} \cdot \frac{8!}{(8-3)!}}\right)$$