Arranging colored balls in a line. 2 balls from 5 distinct colors are collected.


*

*In how many ways can the balls be arranged?

*In how many ways can the balls be arranged so that no two balls of the same color are next to one another?


The first is easy.  If I have 10 spots and 10 balls, then I have 10 choices in the first place, 9 in the second, and so on.  This yields $10!$ ways.
The second is somewhat of a curve ball.  I suppose that the answer would be $10! - N $, where $N$ is the number of arrangements with at least one pair of balls next to one another.  I'm not sure how to approach finding $N$ and would like some help.
Thanks

For the first case, we could arrange the balls in $10!$ different ways if they were unique. However, they aren't unique.  For each color, there are two balls.  Therefore, we can swap any of the balls that are the same color and have the same arrangement, so there are $2!$ different arrangements that are the same for each color. Therefore, we get $\frac{10!}{(2!)^5}$ different ways to arrange the $10$ colored balls. We have the $10!$ for each arrangement and divide by $2!$ $5$ times for the $5$ different colors.

For the second question, this requires the inclusion exclusion principle.  First we must find the number of combinations with one color next to the same colored orb.  To do this, suppose that, say the blue balls, are one unit.  Then there are $\frac{9!}{(2!)^4}$ arrangements where the blue balls are next to each other.  We continue pairing colors that will become a unit like this and then apply the inclusion exclusion principle to see that the number of arrangements where no two similarly colored balls are next to each other is given by the following equation:
$\frac{10!}{(2!)^5}-{5\choose1}\frac{9!}{(2!)^4}+{5\choose2}\frac{8!}{(2!)^3}-{5\choose3}\frac{7!}{(2!)^2}+{5\choose4}\frac{6!}{(2!)^1}-{5\choose5}\frac{5!}{(2!)^0}=39,480$
I only very briefly explained the use of the Inclusion-Exclusion Principle, but you can find more at its wikipedia page 
