<s>[INST] Arrangements of $a,a,b,b,b,c,c,c,c$ in which no two consecutive letters are the same I have the following question:

We are going to generate permutations from a,a,b,b,b,c,c,c,c. Please compute the number of permutations such that:
(a) for any consecutive 4 elements, they are not all the same;
(b) for any consecutive 3 elements, they are not all the same;
(c) for any consecutive 2 elements, they are not all the same.


See Arrangements of $a,a,b,b,b,c,c,c,c$ in which no four/three/two consecutive letters are the same for the first two parts.
I got an answer for part c but I am not sure if it is correct or not.
My step is the following.
I found that there are six pairs containing adjacent identical letters. I will define them as$S_1, S_2,..., S_6$ the small number is the number of pairs of adjacent identical letters.
$$S_0 =\binom{9}{2,3,4}$$
$$S_1 =\binom{8}{3,4} + \binom{8}{2,4} + \binom{8}{2,3,2}$$
$$S_2 = \frac{7!}{4!}+\binom{7}{3,2}+\binom{7}{4,2} + \binom{7}{3,2} + \binom{6}{3,2}+\binom{7}{2,2}$$
$$S_3 = \frac{6!}{4!}+\frac{6!}{3!}+\frac{5!}{3!} + \binom{6}{2,2} + \frac{6!}{2!} + \frac{5!}{2!}$$
$$S_4 = \frac{5!}{2!}+\frac{5!}{3!}+\frac{5!}{2!} + \frac{5!}{2!} + {5!}+{4!}$$
$$S_5 = {4!}+{3!}+\frac{4!}{2!} $$
$$S_6 = 3!$$
I sum these up by the inclusion-exclusion principle, and I got the answer of the following:
$$N = S_0 - S_1+ S_2- S_3 +S_4 -S_5+ S_6 = 473$$
I want to know if there is any miscalculation or if the wrong steps exist. Could anyone please help?
 [/INST] This answer is rather a supplement which could be used as crosscheck for manual calculations. We consider a $3$-ary alphabet built from letters $\mathcal{V}=\{a,b,c\}$. Words which do not have any consecutive equal letters are called Smirnov words. A generating function for Smirnov words is given as
\begin{align*}
\left(1-\frac{az}{1+az}-\frac{bz}{1+bz}-\frac{cz}{1+cz}\right)^{-1}\tag{1}
\end{align*}
The coefficient $[z^n]$ of $z^n$ in the series (1) gives the number of $3$-ary words of length $n$ which do not have any consecutive letters.

With some help of Wolfram Alpha we calculate the answer from (1) as
\begin{align*}
\color{blue}{[z^{9}a^2b^3c^4]\left(1-\frac{az}{1+az}-\frac{bz}{1+bz}-\frac{cz}{1+cz}\right)^{-1}=79}
\end{align*}

Note: Smirnov words can be found for instance in example III.24 in  Analytic Combinatorics by P. Flajolet and R. Sedgewick.
</s>