How many series of length $n$ combined from the numbers $0,1,3,4$ , that don't contain the sequences $04,40,13,31$ or $0X0, 1X1, 3X3, 4X4$ are there? How many series of length $n$ combined from the numbers ${0,1,3,4}$ , that don't contain the sequences $04,40,13,31$ or $0X0, 1X1, 3X3, 4X4$ (where X can be any number from $0,1,3,4$) are there?
Let $f(n)$ be the number of the good series of length $n$.
If I start with $1$, then I have $f(n-1)$ options for the rest of the series without limitations, but I have to decrease the series of length $(n-2)$ starting with 3 (so I won't have $13$ in my series) and I have to decrease 3 times the series of length $(n-3)$ starting with 1 (so I won't have $1X1$ in my series).
Overall $f(n)$ is 4 times the process I just did because of symmetry depending on the first number in the series, i.e. $f(n)=4(f(n-1)-f(n-2)-3f(n-3))$.
I know I have a mistake when I'm decreasing the series of length $(n-2)$ becuse I'm decreasing too much.
Would appreciate any help in correcting that mistake.
Thanks:)

As soon as I have a series of length $2$ or more it will end with a pair $\dots ab$
To add $c$ so we get $\dots abc$ we need to make sure that $c\neq a, 4-b$. This excludes two possibilities unless $a=4-b$, but in this case the sequence was already bad, so we can exclude it.
(This can also be used to analyse what happens at the start of the series).
There will be some special cases at the beginning where this analysis does not apply, but here can be done by hand.
I think you have overcomplicated your analysis - the exclusions depend on the actual elements of the series and you need to get under the skin of that before you start counting.
