We call a number to be good if none of two consecutive digits differ by more than one. How many good $n$-digits numbers made from digits $1$, $2$ and $3$ are there?
For example, $12232$ is good, but $12\textbf{31}2$ isn't.
My idea was to subtract bad numbers made of $1$, $2$ and $3$ (bad numbers are ones that aren't good) from $3^n$ (which represents number of $n$-digit numbers made of $1$, $2$ and $3$).
I tried with representing number $abcd$ ($n=4$) as sequence of 3 ($4-1$) pairs of digits: $(a,b),\text{ }(b,c),\text{ }(c,d)$. Then (I think) we could count number of ways to have at least one of the pairs $(1,3)$ and $(3,1) appearing at least once. But alas...
