[Math] Number of arrangements with no consecutive letter the same

combinationscombinatoricspermutations

I was learning the following questions in this site
question 1
question 2
which are indeed similar problems. But, one thing I observed is, in both of these problems, letters are repeating only two times. But, consider the following situation where one letter repeats two times and another three times.

How many arrangements of the letters in the word ABCDDEEE have no
consecutive letter the same?

With similar logic, by applying inclusion-exclusion principle,

Answer must be
$$\dfrac{8!}{2! \times 3!}-\left(\dfrac{7!}{3!}+\dfrac{6!}{2!}\right)+5! =2280$$

But, I have checked with a program and answer appears to be $960$.

Could you please help me to understand why I am going wrong here? If anyone any general approach is there, please suggest.

Best Answer

We shall solve by successively applying the well known "gap" and "subtraction" methods.

Firstly, we shall keep the $E's$ separate by placing them in the gaps of $-A-B-C-D-D-$ and permute the other letters, thus $\binom63\cdot\frac{5!}{2!} = 1200$ ways.

We shall now subtract arrangements with the $D's$ together treating them as a super $D$, $-A-B-C-\mathscr D-$, i.e. $\binom53\cdot4!= 240$

Thus we get $1200-240 = \boxed{960}$