I came across this question on Quora and got interested in solving it.
Being given a number $m$ of objects of type A and a number $n$ of objects of type B, in how many ways can we create a bigger object of length $m+n$ combining them, such that in the final object there are not more than $2$ consecutive objects of type B?
Take away $2x$ number of objects of type B and create a new type called C such that— each object of type C is made up of two objects of type B.
Now we have: $\displaystyle \begin{array}{|c|c|} \hline \text{Type} & \text{No. of objects}\\ \hline A & m\\ \hline B & n-2x\\ \hline C & x\\ \hline \end{array} \tag*{}$ Let’s represent objects of type B by | (lone pipe) and type C by || (double pipe). We need to arrange the objects of type A (represented by period .) in between the arrangements of objects of types B and C. $\underbrace{…}_{a_0}|\underbrace{…}_{a_1}||\underbrace{…}_{a_2}||\cdots\cdots|\underbrace{…}_{a_{n-x}}\tag*{}$ Lone pipes and double pipes can permutate in $\displaystyle \frac{(n-2x+x)!}{(n-2x)!\cdot x!}=\binom{n-x}{x}\tag*{}$ ways. The figure is only representational, we are not sure about the order.
Number of ways to arrange $m$ periods in between those lone and double pipes can be given by the number of non-negative integer solution sets of the following equation: $m=a_0+(1+a_1)+(1+a_2)+\ldots+(1+a_{n-x-1})+a_{n-x}\\ \displaystyle \implies m -(n-x-1) = \sum_{i=0}^{n-x}a_i\tag*{}$ This equation has $\displaystyle \binom{m-(n-x-1)+n-x}{n-x}=\binom{m+1}{n-x}\tag*{}$ non-negative integer solution sets. (Why?).
Hence, we have $\displaystyle \binom{n-x}{x}\cdot \binom{m+1}{n-x}\tag*{}$ ways of arranging the double pipes, lone pipes and periods.
Now the number of double pipes can be varied from $0$ to $\lfloor n/2\rfloor$ which gives us: $\displaystyle \color{red}{\boxed{\sum_{x=0}^{\lfloor n/2\rfloor}\binom{n-x}{x}\cdot \binom{m+1}{n-x}}}\tag*{}$
I am not sure if this has a closed form or there is any mistake in my assesment. Any help or alternate solution would be appreciated.
Here is an alternative solution that confirms OPs result. We consider a binary alphabet built from letters $A,B$. Words which do not have any consecutive equal letters are called Smirnov words. A generating function for Smirnov words is given by \begin{align*} \left(1-\frac{Az}{1+Az}-\frac{Bz}{1+Bz}\right)^{-1}\tag{1} \end{align*} The coefficient $[z^n]$ of $z^n$ in the series (1) gives the number of binary words of length $n$ which do not have any consecutive letters.
Putting (2) into (1) we derive the generating function \begin{align*} &\left(1-\frac{\frac{Az}{1-Az}}{1+\frac{Az}{1-Az}}-\frac{Bz+B^2z^2}{1+Bz+B^2z^2}\right)^{-1}\\ &\qquad=\left(1-Az-\frac{Bz+B^2z^2}{1+Bz+B^2z^2}\right)^{-1}\\ &\qquad\,\,\color{blue}{=\frac{1+Bz+B^2z^2}{1-Az\left(1+Bz+B^2z^2\right)}}\tag{3} \end{align*}
Comment:
In (3.1) we use the geometric series expansion.
In (3.2) we select the coefficient of $A^mz^m$.
In (3.3) we apply the rule $[z^p]z^qA(z)=[z^{p-q}]A(z)$.
In (3.4) we select the coefficient of $B^{n-k}z^{n-k}$.
Note: Smirnov words can be found for instance in example III.24 in Analytic Combinatorics by P. Flajolet and R. Sedgewick.