[Math] Number of $11-$digit length number with all $10$ digits and no consecutive same digits

combinatoricsdiscrete mathematics

Here is the question:

In how many ways we can construct a $11-$digit long string that contains all $10$ digits without $2$ consecutive same digits.

Initially, I came up with $10!9$. I thought that there are $10!$ ways to construct $10-$digit number with all $10$ digits. And I can add one more digit at the end of each number in $9$ ways.

However, I found that may wrong. Because I when applied the same rule to $4-$ digit number with $3$ digits $(0,1,2)$, the answer is not $3!2$. For example, it doesn't contain $1210, 2120, 0102, …$

So how to approach this problem?

Best Answer

All your desired strings have one digit that occurs twice, while the others occur once. So here is a method to get all those strings:

  1. Place all ten digits into a ten-digit string. This can be done in $10!$ ways.
  2. Choose one digit to be the repeated digit. This can be done in $10$ ways.
  3. Choose a position in the ten-digit string from step $1$ to insert that repeated digit. The ten-digit string has $11$ places to insert, but $2$ of them are next to the same digit, so there are $9$ allowable places to insert the digit.

Inserting the digit into the position in the ten-digit string gives us an allowable eleven-digit string. However, we have double-counted every eleven-digit string, since we could have inserted the other occurrence of the repeated digit. So we must divide our count by two.

Our final count is then

$$\frac{10!\cdot 10\cdot 9}2=163,296,000$$

In your check of $4$-digit strings with $3$ digits, that would be

$$\frac{3!\cdot 3\cdot 2}2=18$$

A quick check of that in MS Excel confirms that is correct. (For the $4$-digit strings: even Excel doesn't easily handle over one hundred million lines!)