Sequences without repeated objects 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.
 A: 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.
A: See
L. Q. Eifler, K. B. Reid Jr., D. P. Roselle,  Sequences with adjacent elements unequal. Aequationes Mathematicae 6:2-3 (1971), 256-262.
http://dx.doi.org/10.1007/BF01819761
P.S. I have a PARI/GP implementation of the formula from this paper at http://home.gwu.edu/~maxal/gpscripts/
