Puzzle, Permutation and Combination problem? 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.
 A: 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$.
A: 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).
