Find and solve a recurrence equation for the number gn of ternary strings of length n that do not contain $102$ as a substring.
I am having some trouble finding the recurrence relation for this question. My thinking is that you can set this problem into cases. If the last digit of the ternary string is $0,1$,or $2$, then there is $3g(n-1)$ possible cases of length $n-1$. Then, continue to do the same for the next digits.
Any help would be appreciated. Thanks!