Is a closed form for quaternary sequences avoiding some patterns known? Let $a_n$ be the number of quaternary strings over $\{0,1,2,3\}$ of length $n\geq 1$ not containing the substrings $02,03,12,20,21,$ and $30.$
Is there a known closed form for $a_n$ which has appeared in the literature?
 A: By interchanging the roles of 2 and 3, we see that this is the number of length-$n$ quaternary strings with adjacent digits differing by at most one, which is OEIS A126358, where the formula $2 F_{2n+1}$ is given.  You can prove this formula inductively by noting that the number of walks of length $n$ in the corresponding directed graph is obtained by summing the elements of the $n$th power of the adjacency matrix $$\begin{pmatrix}1&1&0&0\\1&1&1&0\\0&1&1&1\\0&0&1&1\end{pmatrix}.$$
A: The general way to do this is to count a few more precise quantities: let's consider, for $s\in\{0,1,2,3\}$ the quantities $b_{n,s}$ be the number of strings of length $n$ that avoid the list of strings you give and end with the letter $s$.
You can note that you get relations such as $b_{n+1,2}=b_{n,2}+b_{n,3}$ since a string of length $n+1$ ending in $2$ and avoiding the given substrings is just a string of length one less that does not end in a forbidden substring - hence that ends either $22$ or $32$. You can write out such a relation for every $s$ to get the values of $b_{n+1,s}$ as some linear combinations of the values $b_{n,s}$. You may express this as a matrix by writing
$$\begin{pmatrix}1 & 1 & 0 & 0\\
1 & 1 & 0 & 1\\
0 & 0 & 1 & 1\\
0 & 1 & 1 & 1\end{pmatrix}\begin{pmatrix}b_{n,0}\\b_{n,1}\\b_{n,2}\\b_{n,3}\end{pmatrix}=\begin{pmatrix}b_{n+1,0}\\b_{n+1,1}\\b_{n+1,2}\\b_{n+1,3}\end{pmatrix}$$
where the $0$ values correspond to forbidden strings. If you just iterate this method starting with $b_{1,s}=1$, you find
$$\begin{pmatrix}1 & 1 & 0 & 0\\
1 & 1 & 0 & 1\\
0 & 0 & 1 & 1\\
0 & 1 & 1 & 1\end{pmatrix}^{n-1}\begin{pmatrix}1\\1\\1\\1\end{pmatrix}=\begin{pmatrix}b_{n,0}\\b_{n,1}\\b_{n,2}\\b_{n,3}\end{pmatrix}$$
which gives a closed form for the values of $b_{n,s}$ for each $s$ and hence, by summing these, for $a_n$. Exactly how you most prefer to deal with the matrix power is a matter of preference - it's fast to compute directly, but could also be decomposed into eigenvalues to give the values as sums of exponentials.
This method works for any similar problem, where you just define enough variables of the form "strings of length $n$ ending in some string $S$" to be able to avoid the forbidden strings and create a linear recurrence.
