The total number of arrangements of a,a,a,b,b,b,c,c,c is . We must subtract from this the number of arrangements with three consecutive letters the same.

Suppose for example that the three c's are consecutive. If we denote the block of three c's by d, then we are looking for the number of arrangements of a,a,a,b,b,b,d, namely . The same applies to the number of arrangements with three consecutive a's or three consecutive b's. That leaves us with 1680 – 3×140 = 1260 arrangements.

But there has been some double counting here. If an arrangement contains three consecutive b'sandthree consecutive c's, for example, we will have subtracted it twice. So we must nowaddthe number of arrangements with two sets of three consecutive letters the same. This will be . Finally (for similar reasons of double counting) we must subtract the number of arrangements with three sets of consecutive letters the same, namely 3!=6.

So the final answer is 1680 – 420 + 60 – 6 = 1314.