Originally Posted by

**JeffM** Let's try it your way.

Why 8!. Ignoring the restriction against the two yellow cars being placed adjacently and putting signs on the red cars marked a, b, and c, on the blue cars marked d, e, and f, and on the yellow cars marked g and h, you can indeed form 8! distinguishable lines.

Now remove the signs from the red cars. The sign marked a could be on the first red car from the left, or the second red car from the left, or the rightmost red car. That's 3 possibilities. That leaves 2 red cars that could have the sign marked b. So removing the signs from the red cars reduces the number of distinguishable lines by a factor of 6 = 3!. Now remove the signs from the blue cars. Another reduction by a factor of 3!. Now remove the signs from the yellow cars. A reduction by a factor of 2 = 2!. So the relevant number of distinguishable lines, ignoring the restriction on adjacently placed yellow cars, is

$\dfrac{8!}{3! * 3! * 2!} = \dfrac{8 * 7 * 6 * 5 * 4 * 3 * 2}{3 * 2 * 3 * 2 * 2} = 8 * 7 * 5 * 2 = 560.$

Now if you follow the same logic with respect to just red and blue cars, you get the number of distinguishable lines of cars as

$\dfrac{6!}{3! * 3!} = 5 * 4 = 20.$

(This by the way is Plato's starting point, but we are doing this your way.)Now let's think where we can put two yellow cars adjacent to one another.

They could go in positions 1 and 2, or 2 and 3, or 3 and 4, etc for a total of 7 possibilities . So the possible arrangements with two adjacent yellow cars is

$7 * 20 = 140$.

Thus, the answer is $560 - 140 =420$ which Plato got by a slightly different method.