So I need to find a correct recurrence relation to this problem:
How many series of size n over {0,1,2} exist, so that each digit never appears alone. For example, this series is good: 000110022, and this series is bad: 000122.
I did find a correct relation: $f(n) = f(n-1) + 2*f(n-2)$ or $f(n) = 3*f(n-2) + 2*f(n-3)$ (both work. But I have no idea how to explain them. I found them just by brute force.
I would think that $f(n) = 3*f(n-2) + 3*f(n-3)$ minus the intersection between the two, but again it seems as though that intersection is $f(n-3)$ (according to the above relation), and I have no idea why.
Any help would be appreciated. Thanks!
P.S. $f(1) = 0, f(2)=3, f(3)=3, f(4)=9, f(5)=15$