Find the number of five-digit strings, using digits from $\{0, 1, . . . , 9\}$ in which there are no three consecutive equal digits.

791 Views Asked by At

(Hint: Let $A$ be the set of strings in which the first three digits are all equal.)

Originally I thought of creating sets with three consecutive equal digits
($A_{0}:\{0,0,0\},\ A_{1}:\{1,1,1\},...,\ A_{9}:\{9,9,9\}$) and using inclusion/exclusion to solve. However, I soon realized that I was completely confused. I have no idea how I should solve this problem, and the hint isn't really clicking with me.

Please help me. Thank you!

2

There are 2 best solutions below

1
On BEST ANSWER

Let's count the forbidden strings. They cannot contain more than one run of length $\geq3$. This leaves the following types, where $b$ denotes the bad digit, $x$ is placeholder for digits $\ne b$, and $y$ can be any digit: $$bbbxy,\quad yxbbb,\quad xbbbx,\quad bbbbx,\quad xbbbb, \quad bbbbb\ .$$ The first two can be realized in $10\cdot 9\cdot10$ ways each, the next in $10\cdot9^2$ ways, the next two in $10\cdot9$ ways each, and the last one in $10$ ways. It follows that there are $2800$ forbidden strings, hence $10^5-2800=97\,200$ admissible strings.

0
On

Let $A_i$ be the set of 5-digit strings with digits $i, i+1, i+2$ equal, for $1\le i\le 3$.

If $S$ is the set of all 5-digit strings, then

$\displaystyle\big|\overline{A_1}\cap\overline{A_2}\cap\overline{A_3}\big|=|S|-\sum_{i}\big|A_i\big|+\sum_{i<j}\big|A_i\cap A_j\big|-\big|A_1\cap A_2\cap A_3\big|$

$\hspace{1 in}=10^5-3\cdot10^3+(10^2+10^2+10)-10=97,200$