# I have five eggs to color for Easter. I can color them red, yellow, or blue. How many ways are there to do this?

Not sure if my thinking is correct on this problem. I have five eggs to color for Easter. I can color them red, yellow, or blue. How many ways are there to do this?

I was thinking 5 * 5 choose 3 since you would have 3 choices for color for each egg. Not sure if this would be correct though. Let me know what you think.

## 5 Answers

Consider a simpler problem. Suppose that you have just one egg. How many ways are there to color that egg using red, yellow or blue? The answer is: $3$, right?

Now, instead of one egg, you have two. How many ways can you color the second one? The answer is again $3$, right?

But, recall that you had $3$ ways to color the first egg. Thus, for every possible color choice for the first egg, you can color the second one in $3$ ways. Therefore, the two eggs can be colored in $3 * 3$ ways.

So, the final answer is ...?

• Wouldn't this assume that colouring the first egg blue and the second egg red is different than first egg red and second egg blue? For example, if two colours, R and B then there are three options, namely both B, both R, one each of B and R. – muffle Oct 22 '13 at 16:08
• Sure. My answer assumes that the eggs are somehow different (perhaps they are labelled $1, 2, ..$ etc. – response Oct 22 '13 at 16:15
• I don't think that's the right answer. In real life, you can't distinguish the eggs. – Bman72 Jun 6 '18 at 14:07

Let us assume that order does not matter, and that eggs of the same colour are indistinguishable. Then the problem is a standard Stars and Bars problem. The Wikipedia link gives a quite thorough explanation.

Briefly, we find the number of ways to distribute $5$ eggs (candies) between $3$ colours (kids). One or more kids may get nothing.

It is easier to think of the distribution as going as follows. We distribute $8=5+3$ candies among the $3$ kids, at least one to each kid, and then take away a candy from each kid. Or, if you want to be less cruel, we assign colours to $8$ eggs, with each colour being used on at least one egg, and then eat an egg of each colour.

Put down the $8$ candies like this $$\ast \qquad \ast \qquad\ast \qquad\ast \qquad\ast \qquad\ast \qquad\ast \qquad\ast$$ This determines $7$ intercandy gaps. Choose $2$ of these gaps to put a separator into, perhaps like this $$\ast \qquad \ast \quad|\quad\ast \qquad\ast \qquad\ast \qquad\ast \quad|\quad\ast \qquad\ast$$

This means Kid Red gets $2$ candies, Kid Yellow gets $4$, and Kid Blue gets $2$.

There are just as many ways to insert the two bars as there are to distribute the $8$ candies, at least one to each kid. Since there are $7$ intercandy gaps, there are $\binom{7}{2}$ ways to do the job.

Remark: For our case of $5$ and $3$, and indeed $n$ and $3$, the explicit enumeration of the answer by drhab is I think better. But the Stars and Bars technique comes up fairly often, so it is a good idea to get some exposure to it.

If the order of colouring is relevant then look at the other answers. If not then you must look in how many different ways $5$ can be written as sum of three nonnegative integers. You have $5=R+Y+B$ and:

$5=5+0+0$

$5=4+1+0$

$5=4+0+1$

...

et cetera. This gives $1+2+3+4+5+6=21$ possibilities.

First egg you can color red, yellow or blue, for second you can also use red, yellow or blue. This can be applied for each egg.
So you have $$3^5$$ options to color eggs.
For $n$ eggs and $k$ colors you can use $k^n$ options to color eggs.
For example(binary coding): You have two colors $k=2$ (red, blue; green, black; 1, 0;...) and you have $n=3$ eggs, you can color this by $2^3=8$ ways:

1. $0,0,0$, or $red,red,red$(for red and blue colors)
2. $0,0,1$, or $red,red,blue$
3. $0,1,0$, or $red,blue,red$
4. $0,1,1$, or $red,blue,blue$
5. $1,0,0$, or $blue,red,red$
6. $1,0,1$, or $blue,red,blue$
7. $1,1,0$, or $blue,blue,red$
8. $1,1,1$, or $blue,blue,blue$
• Aren't the (blue, red, blue) and the (blue, blue, red) both the same coloring? – Jeyekomon Oct 22 '13 at 21:20

You have five eggs and three colors. Here is a brute force approach: five all the same color say there will be three of these B - blue, R- Red, W white BBBBB,RRRRR,WWWWW When we have two colors in play there can be either RB, RW, or BW say RBBBB BWWWW RWWWW RRBBB BBWWW RRWWW RRRBB BBBWW RRRWW RRRRB BBBBW RRRRW So that would add 12 more. When there are three colors we would have RBW + either BB,WW,RR, or BW, BR, RW giving RBWRR RBWBW RBWBB RBWBR RBWWW RBWRW for the remaining eggs This adds six more for a total of 21 ways of displaying three colors around 5 eggs.

Not sure if I'm overlooking something obvious. Is there a neat way of solving this with the permutation/combination formulation?

• Yes there is, for $n$ eggs and $k$ colours: Stars and Bars. The answer is $\binom{n+k-1}{k-1}$. – André Nicolas Oct 22 '13 at 20:58