Find the number of 6-digits number with no 3 consecutive number with same digits. Note that 0 might be the first number.
I have tried to find the number with no pairs, 1 pairs, 2 pairs and 3 pairs. And I get the answer of 333360. It seems like my answer is wrong.
We approach by Inclusion-Exclusion.
Without restrictions on consecutive numbers, there are $10^6$ possibilities.
If there is at least one digit occurring 3 times in a row, then we have numbers of the form:
Where $d$ is a fixed digit and $x$ can be any digit and $y$ can't be $d$. This way, we avoid to count twice cases like $2\;0\;3\;3\;3\;3$. Thus, for each fixed digit d, there are $(10 + 3\cdot 9) \cdot 10^2 = 37 \cdot 10^2$ numbers with $d$ occurring at least 3 times. As there are 10 choices for $d$, we have $37 \cdot 10^3$ numbers to disconsider. Up until now, we have $10^6 - 37 \cdot 10^3$ numbers.
But then some numbers, like $2\;2\;2\;5\;5\;5$ are being thrown out twice, both when $d = 2$ and $d = 5$. We have to add back numbers of the form $a\;a\;a\;b\;b\;b$. There are $10$ choices for $a$ and $9$ choices for $b$, as the case $a = b$ occurs only once. Hence there are $90$ numbers of that form.
Therefore, we have a total of: $$10^6 - 37 \cdot 10^3 + 90 = 963090$$