Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a puzzle here:

There are five colored balls: 2 green, 2 blue and 1 yellow

Rule 1: All balls of the same color must be adjacent to each other.

I wrote a program to find all the solutions for it. I got 24 solutions. But, how do I know that my program's calculation is right? In short I need some mathematical solution for this problem. I'm guessing I need permutation to solve this but the rule threw me off. Any help would be much appreciated. Thanks in advance guys.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You don't say exactly what you want to do with the balls, but I assume you want to place them in a line.

First, decide if the green balls will appear first, or the blue balls will appear first; you have 2 choices.

Then decide whether the yellow ball will be first, in between, or last. You have three choices.

Since both things must be chosen and the choices are independent, you multiply the numbers to get the total number of ways of doing it: $2\times 3$ or $6$ ways.

This assumes that you cannot distinguish between the two green balls, and you cannot distinguish between the two blue balls. If you can distinguish them, then you also need to decide (i) which green ball goes first (2 possible choices); and (ii) which blue ball goes first (2 possible choices). So the total number of ways would then be given by $2\times 3\times 2\times 2 = 24$ (the first 2 determines whether green or blue goes first; the 3 is the number of ways to place the yellow ball; the second 2 is the number of ways of deciding which green ball goes first among the green balls; the last 2 is the number of ways of deciding which blue ball goes first among the blue balls).

share|improve this answer
    
Yes, I wanted to put them in line. Thank you for your help. –  eggman20 May 11 '11 at 2:35

Join the greens with a green stick, the blues with a blue stick.

Now consider placing the sticks and the yellow ball. This can be done in $3! = 6$ ways. Assuming the green balls are distinct and blue are distinct, there are 2 ways to place each of the 2 sticks. So total is $6 \times 2 \times 2 = 24$.

share|improve this answer
    
Wow I didn't thought of it that way. Thanks. But I have another question though, what if the green and blue balls are not distinct? –  eggman20 May 11 '11 at 2:26
    
@eggman20: if you cannot distinguish the green balls between them, or the blue balls between them, then all you need to do is decide which goes first, and where the yellow fits; that's the $6$ ways Moron mentions first. –  Arturo Magidin May 11 '11 at 2:37
    
Thats what he has explained in the first two sentences. They may be considered as one entity if they aren't distinct. So the three entities can be placed in 3!=6 ways. –  Shahab May 11 '11 at 2:39
    
Moron you have become Aryabhatta. Hopefully after sometime Bhaskaracharya. –  user9413 May 13 '11 at 7:19
    
@Chandru: Probably not :-) –  Aryabhata May 13 '11 at 7:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.