Say I have $N = n\_1 + \ldots + n\_d$ balls, with $n\_1$ balls of color $c\_1$,... , $n\_d$ balls of color $c\_d$. How many ways can I arrange all $N$ balls in a sequence so that no two balls of the same color are adjacent? (Some choices of the numbers $n\_1$, ..., $n\_d$ are inadmissible.) I apologize if this is a basic question. I am especially interested in the case when $N$ is large.



Sequences without repeated objects
Let $g\_i(x\_1,\dots,x\_d)$ be a sum of $x\_1^{n\_1}\dots x\_d^{n\_d}$ over all such sequences in which $c\_i\geqslant 1$ and the last ball has color $c\_i$. Then $g\_i=x\_i+x\_i \sum\_{j\ne i} g\_j$. The generating function for what you ask about is $g:=1+g\_1+\dots+g\_d$. 


Solve above linear system of $d$ equations $g\_1,\dots,g\_d$. Divide $i$-th equation by $x\_i$ and add $g\_i$ to both sides, we get $g\_i(1+x\_i^{-1})=g$, $g\_i=\frac{x\_i}{1+x\_i}g$, summing up we get $g-1=\sum\_i g\_i=g\sum\_i \frac{x\_i}{1+x\_i}$, $$g=\left(1-\sum\_{i=1}^d \frac{x\_i}{1+x\_i}\right)^{-1}.$$


Now if you are looking for the asymptotics for large $N$ and, say, $m\_i=\lambda\_iN+o(N)$, $\lambda\_1+\dots+\lambda\_d=1$, we may estimate it from above as $$x\_1^{-m\_1}\dots x\_d^{-m\_d}g(x\_1,\dots,x\_d),\,\forall \{x\_i\}: x\_i>0,\sum\_{i=1}^d \frac{x\_i}{1+x\_i}<1.$$ Minimizing we see that the minimum is achieved near a point of the surface $\sum\_{i=1}^d \frac{x\_i}{1+x\_i}=1,x\_i>0$, onto which $\prod x\_i^{-m\_i}$ takes minimal possible value $A$, and for large $N$ we get the estimate about $A^N$ (it is exponentially sharp, but for justifying this claim some additional words have to be said.) Applying Lagrange multipliers method we see that in a minimzer point the vectors $\{x\_i/(1+x\_i)^2\}$ and $\{\lambda\_i\}$ must be proportional, or, if denote $x\_i/(1+x\_i)=p\_i$, the first vector may be rewritten as $\{p\_i(1-p\_i)\}$. Coefficient of proportionality is a root of some specific though bit ugly equation.


