Simple String of 6-digits This is the problem:

A string of 6 digits, each taken from the set $[0, 1, 2]$ is to be formed. The string should not contain any of the substrings $012$, $120$, and $201$. How many such 6-digit strings can be formed?


I really have trouble in using PIE in here. I'm badly needing some clear explanation in the PIE part because it's not what I usually deal with.
I have also a question: 'Does avoiding $000$, $111$, and $222$ instead will still gain the same result?'.
Thanks for all the help in advance :)

You want to avoid 12 properties:
\begin{matrix}
000xxx & x000xx & xx000x & xxx000 \\
111xxx & x111xx & xx111x & xxx111 \\
222xxx & x222xx & xx222x & xxx222 \\
\end{matrix}
The inclusion-exclusion formula is $$\sum_{k=0}^{12} (-1)^k N_k,$$
where $N_k$ is an overcount of the number of $6$-strings that satisfy $k$ properties.  Clearly, $N_k=0$ for $k>4$.
We have
\begin{align}
N_0 &= \binom{12}{0} 3^6 = 729 \\
N_1 &= \binom{12}{1} 3^{6-3} = 324 \\
N_2 &= 2 \binom{3}{2} 3^{6-6} + 3 \left(3 \cdot 3^{6-4} + 2 \cdot 3^{6-5} + 1 \cdot 3^{6-6}\right) = 108 \\
N_3 &= 3 \left(2 \cdot 3^{6-5} + 2 \cdot 3^{6-6}\right) = 24 \\
N_4 &= 3 \left(1 \cdot 3^{6-6}\right) \\
\end{align}
Putting it all together, we obtain
$$729 - 324 + 108 - 24 + 3 = 492$$
