[Math] How many arrangements of these letters are there with no pair of consecutive letters the same

inclusion-exclusion

Given $2n$ letters, two of each of $n$ types. How many arrangements of these letters are there with no pair of consecutive letters the same?
Please check my solution and tell me where my mistake is!

So such arrangements where the pairs of identical letters are distinguishable. Then $∑^n_k (−1)^k2^k(2n−k)! C(n,k)$ gives the number of such arrangements by inclusion-exclusion (there are $(2n−k)!$ ways for $k$ given pairs to be together (by merging the those pairs into single elements) and the rest arbitrarily ordered, $2^k$ ways to order within those given pairs, and $C(n, k)$ ways to pick those $k$ pairs).So we can obtain the formula :$∑^n_k(−1)^k2^k(2n−k)!C(n,k)$.

Best Answer

Calculating the number $a_n$ of valid arrangements of $2n$ letters with two of each of $n$ types for small values $n=1,2$ we obtain $\color{blue}{a_1=0}$ and $\color{blue}{a_2=2}$. So, there are no valid arrangements of length two and two valid arrangements of length four. Assuming an alphabet $\{a,b\}$ we obtain \begin{align*} \color{blue}{abab}\qquad\text{and}\qquad \color{blue}{baba} \end{align*}

Checking the formula \begin{align*} b_n=\sum^n_k (-1)^k2^k(2n-k)! C(n,k) \end{align*} for small values $n=1,2$ results in $b_1=0$ and $b_2=8$, the second value being false.

But in fact there is only a small correction necessary. When considering $2n$ letters with two of each of $n$ types, the number of different arrangements is not $(2n)!$, but instead \begin{align*} \frac{(2n)!}{2^n} \end{align*} For each occurrence of a letter of a specific type two arrangements are to identify (when exchanging the letters of the same type) giving a total of $2^n$ arrangements to identify.

We conclude, the correct formula is \begin{align*} a_n=\frac{b_n}{2^n}=\sum^n_k (-1)^k2^{k-n}(2n-k)! C(n,k) \end{align*} starting with \begin{align*} 0,2,30,264,39480,2631600,241133760,\ldots \end{align*}