How many $8$-digit numbers do not contain the string $55555$?

119 Views Asked by At

I'm having a little trouble figuring out this exercise.

Consider an $8$-digit number. How many numbers do not contain even numbers? How many numbers do not contain the string $55555$?

For the first part I've worked out that since there are only $5$ odd numbers $\{1,3,5,7,9\}$ and a total of $8$ digits the answer is $5^8$, but I don't know how to tackle the second part.

2

There are 2 best solutions below

6
On BEST ANSWER

Edit
First see (all) of the comments following this answer, especially the comments of N.F. Taussig. I overlooked a required subtlety of my approach. I have edited my answer accordingly.

Further, since this subtlety is required by my approach, it is now unclear to me whether Inclusion-Exclusion is more appropriate.


The computation is $T - F$ where $T$ is the total number of 8 digit numbers possible and $F$ is the total number of 8 digit numbers possible that contain "$55555$".

This problem has two wrinkles:

I will start with the arbitrary interpretation that the leftmost digit can be $0$. Then, at the end of my answer, I will adjust, in case this interpretation is outlawed. Although Inclusion-Exclusion is plausible, simplest approach (edit: ??) is to stay with mutually exclusive cases.

$$T = 10^{8}.$$

To compute $F$, I will compute $F_5, F_6, F_7,$ and $F_8$, where $F_k$ denotes how many 8 digit numbers have exactly $k$ $5$'s and have a block of "$55555$".

Then, $$F = F_5 + F_6 + F_7 + F_8.$$

Clearly, $$F_8 = 1.$$

For $F_7$, the gapped digit may not be the 4th or 5th digit (from the left), since the block of "$55555$" must occur. Therefore,

$$F_7 = 6 \times 10^1.$$

Edit
The above computation for $F_7$ is wrong, since it overlooks that $F_7$ represents having exactly seven $5$'s. The correct computation here is

$$F_7 = 6 \times 9^1.$$

For $F_6$, the following locations of the non-5 digits are permissible:
$\{(1,2), (1,3), (1,7), (1,8), (2,3), (2,8), (6,7), (6,8), (7,8)\}$

Therefore,

$$F_6 = 9 \times 10^2.$$

Edit
The above computation for $F_6$ is wrong, since it overlooks that $F_6$ represents having exactly six $5$'s. The correct computation here is

$$F_6 = 9 \times 9^2.$$

For $F_5$, the string of "$55555$" must begin on digit positions $1,2,3$ or $4$.

Therefore,

$$F_5 = 4 \times 10^3.$$

Edit
The above computation for $F_5$ is wrong, since it overlooks that $F_5$ represents having exactly five $5$'s. The correct computation here is

$$F_5 = 4 \times 9^3.$$


If leftmost digit can not be $0$:

Edit
In this section, I apply all of the editing needed, without elaboration, re $F_k$ represents the situation where exactly $k$ $5$'s are present.

The first adjustment is

$$T = 9 \times 10^7.$$

For $F_8$, no adjustment is necessary.

For $F_7$, if the gapped digit is the 1st digit from the left, then there are only 8 choices for the 1st digit (i.e. the first digit can not be a $0$ or a $5$). If instead, the gapped digit is any of digit positions $2,3,6,7,8$, then in each case, there are 9 possible digits for the gapped position.

Therefore $$F_7 = 8 + (5 \times 9) = 53.$$

For $F_6$, of the 9 permissible locations for the non-5 digits, 4 of the 9 involved the 1st digit. When the first digit is involved, there are only ($8 \times 9 = 72$) possibilities, instead of ($9^2$).

Therefore, $$F_6 = (4 \times 72) + (5 \times 81).$$

For $F_5$, if the leftmost digit occurs in the 1st slot, the enumeration of $(9^3)$ stands. If it begins in the 2nd, 3rd, or 4th slot, then the enumeration becomes $8 \times 9^2.$

Therefore $$F_5 = 729 + (3 \times 648).$$

1
On

If $55555$ appears as a (consecutive) substring, its earliest appearance begins with one of the first four digits. If that earliest appearance begins with the first digit, then the final three digits can be anything. If it begins with the second, third, or fourth digit, then the digit immediately preceding it cannot be a $5$ but can be anything else, and the remaining two digits, wherever they are, can be anything. Thus the total numbero of eight-digit strings containing $55555$ is

$$10^3+3(9\cdot10^2)=3700$$

so the number of eight-digit strings without $55555$ as a substring is

$$10^8-3700$$