[Math] Arranging $3$ red balls, $2$ blue balls, and $2$ green balls so that no two adjacent balls are of the same color

combinatoricspermutations

I want to arrange $3$ red balls, $2$ blue balls, and $2$ green balls in a line so that no two balls of the same color are adjacent. If there are no such restrictions, then the number of such unique arrangements is

$$\frac{7!}{3!\times 2!\times 2!}=210.$$

I found a related problem here but it does not have an answer. Instead, I wrote a code in R that will completely list all such possible arrangements. I found 38. I also tried to list them manually below.

  • _ B _ G _ B _ G _: $C^5_3=10$ arrangements
  • _ G _ B _ G _ B _: $C^5_3=10$ arrangements
  • _ G R G _ B R B _: 3 arrangements
  • _ B R B _ G R G _: 3 arrangements
  • _ G _ B R B _ G _: $C^4_2=6$ arrangements
  • _ B _ G R G _ B _: $C^4_2=6$ arrangements

Is this correct? Is there a more elegant way of doing this?

Best Answer

There are $10$ ways to arrange the red balls. Of these:

  1. two arrangements leave three adjacent free spots and one solo free spot: $$ R\,\_\,\_\,\_R\,\_R\\ R\,\_R\,\_\,\_\,\_R $$For each of these: Whichever colour is in the middle of the three free spots must also be in the solo spot, so 2 possibilities for each of these arrangements

  2. six arrangements leave two adjacent spots and two solo spots: $$ \,\_\,\_R\,\_R\,\_R\\ \,\_R\,\_\,\_R\,\_R\\ \,\_R\,\_R\,\_\,\_R\\ R\,\_\,\_R\,\_R\,\_\\ R\,\_R\,\_\,\_R\,\_\\ R\,\_R\,\_R\,\_\,\_ $$ and one leaves two pairs of adjacent spots: $$ R\,\_\,\_R\,\_\,\_R $$For each of these: the colours must differ in a pair of adjacent spots, but they can be swapped around, so 4 possibilities for each of these arrangements

  3. one arrangement leaves no adjacent spots: $$ \,\_R\,\_R\,\_R\,\_ $$ Here there are six possible arrangements of the remaining $4$ balls

In total: $$ 2\cdot 2 + 7\cdot 4 + 1\cdot 6 = 38 $$ I don't think there is a more "elegant" way to do this than simply splitting into cases and count. The interactions are too complicated to make inclusion-exclusion viable, and there isn't a simple formula for "non-adjacent" that we can apply. Of course, how you decide to split into cases changes how easy the calculations are and how easily you miss a case or double count.

Related Question