Combinatorics. Find the number of ways....... Need Explanation Find the number of ways to arrange the numbers $ 0, 0, 0, 1, 1, 1, 2, 2, 2$ so that no arrangement ever contains three consecutive integers that are the same.
I have the solution but I don't understand it. Can you explain how its 7!/3!3! and how its 5!/3]1
 A: The count of ways to arrange $\{A,A,A,B,B,B, [CCC]\}$ where the block of three digits, $[CCC]$, is inseparable (a unit), is: $$\dfrac{7!}{3!~3!~\color{silver}{1!}}$$
This is the count of ways to select $3$ of $7$ places for the $A$, $3$ of the remaining $4$ places for the $B$, and all of the $C$ go into the last remaining place.   Because a unit is inseparable it occupies just one place.
We do similar to count the ways to arrange $\{A,A,A,[BBB], [CCC]\}$.   We count ways to select $3$ of $5$ places for the $A$, select $1$ of the remaining $2$ places to put all of the $B$, and all of the $C$ go in the last remaining place. $$\dfrac{5!}{3!~\color{silver}{1!}~\color{silver}{1!}}$$
Finally the count of ways to arrange $\{[AAA],[BBB],[CCC]\}$ is just $3!$.
All that remains is to select which digits are blocked or not, and put it all together using the Principle of Inclusion and Exclusion.$$\frac{9!}{3!^3}-\binom{3}{1}\frac{7!}{3!^2}+\binom{3}{2}\frac{5!}{3!}-3!$$
A: The $\frac {7!}{3!3!}$ comes from considering the three numbers $iii$ as a unit.  You now have seven items, the group $iii$ and the other six numbers.  You can put them in order in this many ways, because you have two groups of three identical items.  $\frac {5!}{3!} comes about from grouping two sets of numbers, so there are five items, the two groups and the three other numbers, of which one set of three is identical.
