Number of strings There are $2^{10} =1024$ possible $10$ -letters strings in which each letter is either an $A$ or a $B$. Find the number of such strings that do not have more than $3$ adjacent letters that are identical.
 A: Let $f(n)$ be the number of strings of length $n$ that begin with A and do not have $4$ or more consecutive  occurrences of the same letter (good strings).  Then the answer to our problem is $2f(10)$.
The second letter could be a B. There are $f(n-1)$ such good strings.
The second letter could be an A, and the next a B. There are $f(n-2)$ such good strings.
The second and third letter could be an A, and the next a B. There are $f(n-3)$ such good strings. 
So for $n\gt 3$ we have $f(n)=f(n-1)+f(n-2)+f(n-3)$. It is easy to see that $f(1)=1$, $f(2)=2$, and $f(3)=4$. Now we can use the "tribonacci" recurrence to climb to $10$.
A: Any allowed string can be seen as a sequence of blocks made of $A$ or $B$ only, whose length is between $1$ and $3$. For instance:
$$ ABBABABBBA \longrightarrow (A)(BB)(A)(B)(A)(BBB)(A)$$
can be associated with the identity: $10=1+2+1+1+1+3+1$. Hence we just have to count in how many ways we can write $10$ as a sum of integers between $1$ and $3$, then multiply such number by two (since we may start with an $A$ or a $B$). So we have that the number of allowed strings is given by twice a tribonacci number:
$$ 2\cdot[x^{10}]\left(\frac{1}{1-(x+x^2+x^3)}\right)=2\cdot 274=\color{red}{548}. $$
