4
  • Suppose you have four pairs of balls, each pair being identical in colour ( say $\color{#00f}{blue}$, $\color{#f00}{red}$, $\color{#06b121}{green}$ and $\color{#d4ac0d}{yellow}$ ).
  • How many ways can they be arranged so that no two identical balls are next to each other ?.

I have an inkling that inclusion/exclusion principle is needed, but I am not completely certain. Also, is there a technique to solve this one out without using inclusion/exclusion principle ?.

Felix Marin
  • 89,464
Trogdor
  • 10,331
  • 2
    In this case, the Inclusion-Exclusion Principle is simpler to apply than placing balls in gaps. Have you attempted to solve the problem using the Inclusion-Exclusion Principle? Where are you stuck? – N. F. Taussig Jul 07 '17 at 08:19
  • You might be interested in "Counting Words with Laguerre Series" by Jair Taylor. http://www.combinatorics.org/ojs/index.php/eljc/article/view/v21i2p1 – awkward Jul 07 '17 at 11:08
  • @awkward: I've added another variant which also might be interesting. – Markus Scheuer Jul 07 '17 at 13:59

5 Answers5

4

This answer is based upon a generating function of generalized Laguerre polynomials \begin{align*} L_k^{(\alpha)}(t)=\sum_{i=0}^k(-1)^k\binom{k+\alpha}{k-i}\frac{t^i}{i!}\tag{1} \end{align*}

The Laguerre polynomials have some remarkable combinatorial properties and one of them is precisely suited to answer problems of this kind. This is nicely presented in Counting words with Laguerre series by Jair Taylor.

We encode the colors (b)lue, (r)ed, (g)reen and (y)ellow of the balls with the letters \begin{align*} \{b,r,g,y\} \end{align*} and are looking for words of length $8$ built from \begin{align*} b,b,r,r,g,g,y,y \end{align*} which have the property that they contain no consecutive equal letters. These words are called Carlitz words or Smirnov words.

We find in section 2 of the referred paper Laguerre polynomials $l_k(t)$ defined by their generating function \begin{align*} \sum_{k=0}^\infty l_k(t)x^k=\exp\left({\frac{tx}{1+x}}\right) \end{align*} The first few such polynomials are \begin{align*} l_0(t)&=1\\ l_1(t)&=t\\ l_2(t)&=\frac{1}{2}t^2-t\\ l_3(t)&=\frac{1}{6}t^3-t^2+t\tag{2} \end{align*} They are a specific form of Laguerre polynomials (1), namely $$l_k(t)=(-1)^kL_k^{(-1)}(t)$$

Theorem 2.1 in the referred paper states: Given nonnegative integers $n_1,\ldots,n_k$, the number of $k$-ary Carlitz words with the letter $i$ used exactly $n_i$ times is \begin{align*} \int_{0}^\infty e^{-t}\left(\prod_{i=1}^kl_{n_i}(t)\right)\,dt\tag{3} \end{align*}

Since we have four characters $b,r,g,y$ each occurring twice, we set \begin{align*} &n_1=n_2=n_3=n_4=2 \end{align*}

We apply theorem 2.1. and obtain using (2) and (3) and with some help of Wolfram Alpha \begin{align*} \int_{0}^\infty&e^{-t}\left(\prod_{i=1}^4l_{n_i}(t)\right)\,dt\\ &=\int_{0}^\infty e^{-t}\left(l_2(t)\right)^4\,dt\\ &=\int_{0}^\infty e^{-t}\left(\frac{1}{2}t^2-t\right)^4\,dt\\ &=\int_{0}^\infty e^{-t}\left(\frac{1}{16}t^{8}-\frac{1}{2}t^{7}+\frac{3}{2}t^{6} -2t^5+t^4\right)\,dt\\ &=\color{blue}{864} \end{align*}

Variation 2:

Another variation is directly based upon a generating function of Smirnov words. (See example III.24 Smirnov words from Analytic Combinatorics by Philippe Flajolet and Robert Sedgewick for more information.)

A generating function for the number of Smirnov words over a four letter alphabet $V=\{b,r,g,y\}$ is given by \begin{align*} \left(1-\frac{4z}{1+z}\right)^{-1} \end{align*}

The number of all Smirnov words of length $8$ over a four letter alphabet is therefore \begin{align*} [z^8]\left(1-\frac{4z}{1+z}\right)^{-1} \end{align*}

Since we want to count the number of words of length $8$ with each character in $V$ occurring twice, we keep track of each character. Again with some help of Wolfram Alpha we obtain \begin{align*} [b^2r^2g^2y^2]\left(1-\frac{b}{1+b}-\frac{r}{1+r}-\frac{g}{1+g}-\frac{y}{1+y}\right)^{-1}=\color{blue}{864} \end{align*}

Markus Scheuer
  • 108,315
3

Here is a pedestrian solution.

Every admissible coloring induces a pairing of $8$ dots in a row whereby no two successive dots are paired. Conversely, each such pairing gives rise to $4!$ admissible colorings.

In order to count the admissible pairings we mark the first element of each pair with a bullet and the second with a circle. The first two spots then are bullets, and the last two circles. There are six ways to put two bullets and two circles in between. The following figure then shows the possible rows of bullets and circles: $$\matrix{ \bullet&\bullet&\bullet&\bullet&\circ&\circ&\circ&\circ\cr \bullet&\bullet&\bullet&\circ&\bullet&\circ&\circ&\circ\cr \bullet&\bullet&\bullet&\circ&\circ&\bullet&\circ&\circ\cr \bullet&\bullet&\circ&\bullet&\bullet&\circ&\circ&\circ\cr \bullet&\bullet&\circ&\bullet&\circ&\bullet&\circ&\circ\cr \bullet&\bullet&\circ&\circ&\bullet&\bullet&\circ&\circ\cr }$$ We now have to pair the circles with allowed bullets to the left of them. The next figure shows how many choices we have, going from left to right. Note that at each step the number of available choices does not depend on the choices made at an earlier stage. $$\matrix{ \bullet&\bullet&\bullet&\bullet&3&3&2&1\cr \bullet&\bullet&\bullet&2&\bullet&2&2&1\cr \bullet&\bullet&\bullet&2&2&\bullet&1&1\cr \bullet&\bullet&1&\bullet&\bullet&2&2&1\cr \bullet&\bullet&1&\bullet&1&\bullet&1&1\cr \bullet&\bullet&1&1&\bullet&\bullet&1&1\cr }$$ Multiply the figures in each row and add up. The result is $36$, so that we have $36\cdot24=864$ admissible colorings in all.

One can set up a recursion for the number of admissible pairings, given $2n$ dots, and obtains the following table: $$0, 1, 5, {\bf 36}, 329, 3655, 47844, 721315, 12310199, 234615096\ .$$ This is A278990 at OEIS, where one may find more information on this sequence.

user84413
  • 27,211
3

Let $S_j$ be the arrangements where the balls of color $j$ are together. Then let $$ N_k=\sum_{|A|=k}\left|\,\bigcap_{j\in A} S_j\,\right| $$ where $A\subset\{1,2,3,4\}$

$\binom{4}{k}$ ways to choose $|A|=k$
$(8-k)!$ ways to arrange the $k$ chosen pairs and $8-2k$ "singletons"
$2^{4-k}$ number of arrangements of the "singletons" that are counted as one

Therefore, $$ N_k=\frac{\binom{4}{k}(8-k)!}{2^{4-k}} $$ The Generalized Principle of Inclusion-Exclusion says that the number of arrangements in $0$ of the $S_j$ is $$ \sum_{k=0}^4(-1)^k\binom{k}{0}\frac{\binom{4}{k}(8-k)!}{2^{4-k}}=864 $$

robjohn
  • 345,667
2

Answer is $864$

suppose we have two blue balls (AA), two red balls (BB), two green balls (CC) and two yellow balls (DD). Then we have the following way of obtaining the answer. This method uses inclusion-exclusion.

enter image description here

Note: generated using Permutations Calculator

Kiran
  • 4,198
2

Let $A_i$ be the set of arrangements where the balls in places $i$ and $i+1$ have the same color, for $1\le i\le 7$.

Using Inclusion-Exclusion,

$\displaystyle\lvert\overline{A_1}\cap\cdots\cap\overline{A_7}\rvert=|S|-\sum_i |A_i|+\sum_{i<j}|A_i\cap A_j|-\sum_{i<j<k}|A_i\cap A_j\cap A_k|+\cdots$

$\displaystyle\hspace{1.0 in}=\frac{8!}{2^4}-\binom{7}{1}\cdot4\cdot\frac{6!}{2^3}+\binom{6}{2}\cdot4\cdot3\cdot\frac{4!}{2^2}-\binom{5}{3}\cdot4\cdot3\cdot2+4!=864$

(where, for example, in the 3rd term there are $\binom{6}{2}$ ways to choose the two pairs of consecutive places, $\;\;\;\;4\cdot3$ ways to color them, and $\frac{4!}{2^2}$ ways to color the remaining places).

user84413
  • 27,211