Find the number of 6-digit numbers made up of the digits $1$, $2$, and $3$ that have no digit occur three or more times consecutively. (For example, $123123$ would count, but $123111$ would not.)
We know the total number of possibilities without the occurrence restriction is $3^6 = 729$.
In order to eliminate the possibilities that can't be used, I set a block of 3 numbers as my 3 consecutive digits block. This block would have 3 different combinations. I then split the number of eliminations into 2 cases: one where the block of 3 is in the front, and one where the block of 3 is in the middle.
For case 1: I computed $3\cdot 24$, with $3$ being the ways to change the block of 3, and $24$ being the number of ways to change the other 3 numbers while not having another block of 3 consecutive.
For case 2: I computed $3^4$, ignoring the restriction of case 1.
Summing the 2 cases, I got $72+ 3\cdot 81 = 315$, I then subtracted from $729$ and got $414$, which turns out to be incorrect. What am I doing wrong?
You are allowed to have pairs of consecutive numbers but no triplets. SO you may have $0,1,2$ or $3$ pairs of pairs of consecutive numbers.
If you have $k$ pairs of consecutive numbers and you consider pairs of consecutive numbers and sington nummbers to be "slots", you have $6 -k$ slots.
There are are ${6-k \choose k}$ to choose which of the $k$ of the $6-k$ slots will be consecutive pairs and which will be singletons.
Given that the slots (whether pair or singleton) may not have any consecutive values, you will have $3$ choices for value of the first slot, and $2$ for the remaining $6-k-1$ slots.
So there will be $\sum\limits_{k=0}^3 {6-k \choose k}3*2^{6-k -1} = 1*3^5 + 5*3*2^4 + 6*3*2^3 + 1*3*2^2 = 492$. ways to do this.
===== earlier but not as clear attempts ====
$aaaxyz$ is unacceptable and there are $3*3^3$ ways to do that.
$abbbxy$ is unacceptable and there are $3*2*3^2$ ways to do that.
$xabbby$ is unacceptable and there are $3*3*2*3$ ways to do that.
$[xyz]aaa$ where it is not the case where $x=y=z$ and $a \ne z$ is unacceptable. There are $3^3 -3$ ways to do $[x=y=z]$ where not $x=y=z$. There are $2$ ways to do $a \ne z$ and so there are $(3^3 - 3)*2$ ways to do this.
So, if I made no error, there are $3^6 - 3*3^3 - 3*2*3^2 - 3*3*2*3 - (3^3 - 3)*2 =492$.
====
Another way:
The number of ways to do is so that there are $0$ consectutive numbers is $3*2^5$ ($3$ choices for the first number and then there every succeeding number must be different that the preceding).
The number to ways to do it so that there is $1$ pair of consecutive numbers it that: there are $5$ spots the consecutive pair can be. There are $3$ options the first number can be and each succeeding must be different than the preceding: $5*3*2^4$.
The number of ways to do it so there are $2$ pairs of consecutive numbers is: There are $3$ ways to place these $2$ pairs so that they are adjacent (a block of $4$ slots) and there $3$ ways to place them so they are not adjacent ([aa]b[cc]d, [aa]bc[dd],a[bb]c[dd]). And there are $4$ groups of letters. So there are $6*3*2^3$ ways to have $2$ pairs of consectutive numbers.
The number of ways to do it with $3$ paris of consecutive numbers is $[aa][bb][cc]$. There are $3$ choices for $a$ and $2$ for $b$ and $2$ for $c$ or $3*2^2$.
So $3*2^5 + 5*3*2^4 + 6*3*2^3 + 3*2^2 = 492$.
===
And although tedious....:
$a.....$ 3 ways
Branch 1: $aab....$ $3*2$ ways.
Branch 2: $ab....$ $3*2$ ways.
Branch 11: $aabbc$ $3*2*2$ ways (we only care that $c \ne b$ we don't care if $c = a$).
Branch 12: $aabc$ $3*2*2$ ways
Branch 21: $abbc$ $3*2$ ways.
Brach 22: $abc$ 3*2*2$ ways.
Branch 111: $aabbcc$ $3*2^2$ ways (done)
Branch 121: $aabccd$ $3*2^3$ ways (done)
Branch 122: $aabcd$ $3*2^3$ ways
Branch 211: $abbccd$ $3*2^3$ ways (done)
Branch 212: $abbcd$ $3*2^3$ ways
Branch 221: $abccd$ $3*2^3$ ways
Branch 222: $abcd$ $3*2^3$ ways.
Braanch 1221: $aabcdd$ $3*2^3$ ways d(done)
Branch 1222: $aabcde$ $3*2^4$ ways (done)
Branch 2121: $abbcdd$ $3*2^3$ ways(done)
Brach 2122: $abbcde$ $3*2^4$ ways (done)
Branch 2211: $abccdd$ $3*2^3$ ways (done)
Branch 2212: $abccde$ $3*2^4$ ways (done)
Branch 2221: $abcdde$ $3*2^4$ ways.(done)
Branch 22221: $abcdee$ $3*2^4$ ways. (done)
Branch 22222: $abcdef$ $3*2^5$ ways. (done)