How many words can be made with $7$ A's, $6$ B's, $5$ C's and $4$ D's with no consecutive equal letters. I would like to know how many $22$ letter words can be made that have exactly $7$ A's, $6$ B's , $5$ C's and $4$ D's and have no consecutive letters the same.
This problem is clearly equivalent to finding the number of ways to partition $[22]$ into $4$ sets of sizes $7,6,5,4$ such that no set contains consecutive integers, or to the number of ways of coloring $P_{22}$ properly using $4$ identical colors, with multiplicities $7,6,5$ and $4$
I have been having a lot of trouble with this question. It is a rather well known result that the number of ways to color any tree with $n$ vertices properly, using $k$ colors is $n-1\brace k-1$. But when we add restrictions to the number of vertices of each color it seems to be harder.
Inclusion-Exclusion seems to be useless also.

Other good answers to this problem can be found here and here
 A: We fill up the positions from left to right. At each step all that matters is how many of each letter we have used up and what is the last letter we used, since it must not be the same as the next. So we can represent all this information as a tuple $(a,b,c,d,x)$ where $a,b,c,d$ are the number of occurrences of respective letters and $x$ is the last letter, say $1,2,3,4$ for 'A','B','C','D' respectively. Naturally let $f(a,b,c,d,x)$ be the number of ways to get to the state $(a,b,c,d,x)$. Clearly then we have the recurrence relation $f(a,b,c,d,1) = \sum_{x\in\{2,3,4\}} f(a-1,b,c,d,x)$. Likewise we have $f(a,b,c,d,2) = \sum_{x\in\{1,3,4\}} f(a,b-1,c,d,x)$, and so on. We can initialize $f(1,0,0,0,1) = 1$ and $f(0,1,0,0,2) = 1$ and so on. This defines a simple recursion to find the answer because we want $\sum_{x\in\{1,2,3,4\}} f(7,6,5,4,x)$.
Of course we must use memoization, which just means storing all previously computed values of $f(a,b,c,d,x)$ so that we do not do duplicate work. This ensures that the recursion goes through each state at most once. Since the total number of states is less than $8^4 \times 4$, this would finish fast. Also, you can prune off some states without even searching them. For example, $f(1,7,3,1,2) = 0$ because there are too many 'B's. This pruning will help decrease the time taken significantly, but it would still be exponential in word length.
A: I do not know whether you still interested in a solution or not , but i wanted to write an answer when i saw it.
To solve this messy process , i will use analytic combinatorics techniques. In analytic combinatorics , we call such arrangements as Smirnov or Carlitz words.I am putting a link for you link of the suggested book You can find detaily explanation here about my method , but i will not get in explanation . When you look at the related pages in book , you will see detailed info.
A generating function for the number of Smirnov words over an n-ary alphabet is given by $$\begin{align*}
\left(1-\frac{nz}{1+z}\right)^{-1}
\end{align*}$$
Here we consider an alphabet $\mathcal{K}=\{A,B,C,D\}$ with $n=4$ letters. Using $[z^k]$ to denote the coefficient of $z^k$ of a series we calculate
\begin{align*}
&\color{green}{[A^7B^6C^5D^4]\left(1-\sum_{a\in\mathcal{V}}\frac{a}{1+a}\right)^{-1}}\\
&\qquad=[A^7B^6C^5D^4]\sum_{j=0}^{\infty}\left(\sum_{a\in\mathcal{V}}\frac{a}{1+a}\right)^j\\
&\qquad=[A^7B^6C^5D^4]\sum_{j=4}^{22}\left(\sum_{a\in\mathcal{V}}\frac{a}{1+a}\right)^j\\
&\qquad=[A^7B^6C^5D^4]\sum_{j=4}^{22}\left((A-A^2 +A^3 -A^4 +A^5-A^6 +A^7 )+\left(B-B^2 +B^3 -B^4 +B^5 -B^6\right)\right.\\
&\qquad\qquad\qquad\qquad\qquad\qquad\left.+(C-C^2 +C^3-C^4 +C^5 )+(D-D^2 +D^3 -D^4)\right)^j\\
&\qquad\\
&\,\,
\end{align*}
I think you can calculate the coefficients of $[A^7B^6C^5D^4]$ in the exapnsion of $[A^7B^6C^5D^4]\sum_{j=4}^{22}((A-A^2 +A^3 -A^4 +A^5-A^6 +A^7 )+(B-B^2 +B^3 -B^4 +B^5 -B^6)
+(C-C^2 +C^3-C^4 +C^5 )+(D-D^2 +D^3 -D^4))^j$ using computer program. I am putting a link of a similar question Link of similar question
