Ternary strings with 3 or more consecutive 2's I'm trying to figure out how to find the number of ternary strings of length $n$ that have 3 or more consecutive 2's.
So far I've been able to establish that there is $n(2^{n-1})$ with a single 2.
And I think (but am not certain) that this can be extrapolated to the number of strings with a single group of 2's of length $x$ by:
$$\bigl(n-(x-1)\bigr)(2^{n-x})$$
What I'm getting caught on is the 'or more part', any help would be greatly appreciated.


We consider the alphabet $V=\{0,1,2\}$ and we are looking for the number $c_n$  of strings of length $n$ having runs of $2$ less than three. The wanted  number is  $$a_n=3^n-c_n$$
We derive a generating function $C(z)=\sum_{n=0}^\infty c_nz^n$ from which the number $a_n$ can be obtained easily since
  \begin{align*}
a_n=[z^n]\left(\frac{1}{1-3z}-C(z)\right)\tag{1}
\end{align*}
  with $[z^n]$ denoting the coefficient of $z^n$ of a series.

Strings with no consecutive equal characters at all are called Smirnov or Carlitz words. See example III.24 Smirnov words from Analytic Combinatorics by Philippe Flajolet and Robert Sedgewick for more information. 
A generating function for the number of Smirnov words over a ternary alphabet $V$ is given by
\begin{align*}
\left(1-\frac{3z}{1+z}\right)^{-1}\tag{2}
\end{align*}
Replacing occurrences of $0$ in a Smirnov word by one or more zeros generates words having runs of $0$ with length $\geq 1$.
\begin{align*}
z\longrightarrow z+z^2+z^3+\cdots=\frac{z}{1-z}
\end{align*}
The  same can be done with the digit $1$.
Replacing occurrences of $2$ in a Smirnov word by one or two $2$'s generates words with runs of $2$ of length less than three.
\begin{align*}
z\longrightarrow z+z^2=z(1+z)
\end{align*}
The resulting generating function is according to (2)
\begin{align*}
\color{blue}{C(z)}=\left(1- 2\cdot\frac{\frac{z}{1-z}}{1+\frac{z}{1-z}}-\frac{z(1+z)}{1+z(1+z)}\right)^{-1}
&\color{blue}{=\frac{1+z+z^3}{1-2z-2z^2-2z^3}}\tag{3}
\end{align*}

We obtain for $n\geq 3$ the number of wanted words of length $n$ according to (1) and (3) as
  \begin{align*}
\color{blue}{a_n}&=3^n-c_n\\
&=[z^n]\left(\frac{1}{1-3z}-\frac{1+z+z^3}{1-2z-2z^2-2z^3}\right)\\
&=[z^n]\left(\color{blue}{1}z^3+\color{blue}{5}z^4+\color{blue}{21}z^5+\color{blue}{81}z^6+\color{blue}{295}z^7+\color{blue}{1\,037}z^8+\color{blue}{3\,555}z^9+\cdots\right)
\end{align*}
whereby the last line was obtained with some help of Wolfram Alpha.

