If there are $10$ blue balls and $10$ red balls. What are the total number of arrangements of these balls such that no three consecutive balls are of the same color?
I attempted this problem by subtracting unfavourable cases from total number of cases.
Unfavourable cases include those formed by permuting balls with a group of $3$ of $1$ color, and then those of another color. And then excluding those formed by permutations of balls with a group of $3$ red balls as well as a group of $3$ blue balls.
But this leaves many cases unattended.
As a brute force approach, divide up each color of balls into sets of size $1$ or $2$ each. Then count the possible number of orderings of each set and then for each partition consider the square of the number of orderings of that partition (if each color is divided into the same number of sets) and also the product with the number of orderings of the next smaller number of sets (if one color both starts and ends the sequence) then multiply by $2$ because either color could have started the sequence. $$\begin{array}{c|cccc}\text{Sets}&\text{Orderings}&\text{Same}&\text{Previous}&\text{Total}\\ \hline5&1&1&0&1\\ 6&15&225&15&240\\ 7&35&1225&525&1750\\ 8&28&784&980&1764\\ 9&9&81&252&333\\ 10&1&1&9&10\\ \hline&&&&4098\end{array}$$ So our final answer is $2\times4098=8196$. As confirmation, I offer total brute force:
Output was