[Math] Number of $2n$-letter words using double $n$-letter alphabet, without consecutive identical letters

combinatoricspermutations

How many words with $2n$ letters can be created if I have an alphabet with $n$ letters and each of the letters have to occur exactly twice in the word, but no two consecutive letters are equal?

Thanks!

Best Answer

There is no simple closed formula for this (I think no known closed formula at all), but one can give a formula as a sum by using inclusion-exclusion.

First consider such orderings where the pairs of identical letters are distinguishable. Then $\displaystyle \sum_{k=0}^n (-1)^k2^k(2n-k)!\binom{n}{k}$ gives the number of such such orderings 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 $\binom{n}{k}$ ways to pick those $k$ pairs). By dividing by $2^n$ to eliminate the ordering of pairs of identical elements we can obtain the formula $\displaystyle \frac{1}{2^n}\sum_{k=0}^n (-1)^k2^k(2n-k)!\binom{n}{k}$.