# Distributing balls in boxes

There are five balls of identical sizes but different colors. One of the balls is red, one is blue, one is green and the other two are yellow. Moreover, there are three boxes which are numbered 1, 2 and 3. There are two more boxes but both of them are numbered 4. In how many different ways can we place the five balls in the given five boxes such that each box contains exactly one ball?

• Have you attempted the problem yourself? – N. F. Taussig Oct 1 '17 at 21:04
• there aren't that many ways... you could list them all, at least schematically; sometimes that helps to makes sense of a problem – Nick Pavlov Oct 1 '17 at 21:09
• I couldn't find a systematic approach to this. I tried multiplying the solutions relating to identical things in different boxes but it doesn't seem to work – uzumaki Oct 1 '17 at 21:10

There are three cases to consider: both yellow balls are in a box numbered $4$, only one is, and neither of them are (you can merge the first two cases into one, but it might be confusing to understand why).

In the first case, you know the nonyellow balls are in boxes $1,2,3$, so you have to permute those three balls.

In the second case, you have to pick which nonyellow ball is in a box numbered $4$, put a yellow ball in the other box numbered $4$, and then permute the other two nonyellows together with the other yellow.

In the third case, you pick which two nonyellows go in the boxes numbered $4$, and then permute the third nonyellow with the two yellows, keeping in mind that the yellow are identical.

One way to do it is to "temporarily mark" the identical balls and boxes so that all balls and boxes are distinguishable. That is, we imagine that we put a sticker on one of the yellow balls and on one of the boxes labeled $4.$

With the stickers, we have five distinguishable balls in five boxes and can apply the known formula for that case.

Now we ask what happens when we remove the stickers. We will "lose" some arrangements because arrangements that were formerly distinguishable are no longer distinguishable. For example, for the arrangement $$(1,R), (2,B), (3,Y), (4,Y), (4,G),$$ without the stickers we cannot tell which of the yellow balls is in box $3$ and we cannot tell which "box $4$" holds the green ball.

For most of the distinguishable arrangements that remain after we remove the stickers, there were four arrangements with stickers; we can count these by choosing which yellow ball has a sticker and which "box 4" has a sticker. There are some arrangements where this four-to-one ratio is not true, however: if both yellow balls are in boxes labeled $4,$ there are only two ways to distinguish arrangements using the two stickers: put the ball with the sticker in the box with the sticker, or put it in the other box.

So you can add up your final answer as follows: from all the arrangements of five distinguishable balls in five distinguishable boxes, take half of the arrangements that put both yellow boxes in boxes labeled $4,$ and add one quarter of the other arrangements.

Try like this:

First choose what goes in the two identical boxes - since they are identical, order doesn't matter, we just pick two of the five balls. The tow yellow balls are a complication though, so I'd count like this: 3 ways to pick non-yellow balls only (choose 2 out of 3), 3 ways to pick one yellow one non-yellow (choose 1 out of 3 - which is the non-yellow), and 1 way to pick 2 yellows: total of 7, but we need the breakdown details for the next part, so 3+3+1.

Then proceed to find in each of these types of configurations, in how many ways you can distribute the remaining 3 balls in the remaining 3 boxes.

Let me distinguish boxes for putting the 2 yellows in.

In Case $\alpha$: ${(1, 2) (1, 3) (2, 3)}$, you need to put two yellow balls into the index of boxes $(1, 2), (1, 3), (2, 3)$. You have 3 s for putting yellow balls into the boxes. Now, you still have one space for the index has not been chosen from $(1, 2, 3)$ and need to put one ball from red, green or blue. So, you have $3$ choices to put into it . If you don't distinguish two yellow balls and two $4$ boxes, you don't have to consider the order of balls has not been chosen from(red, green, blue). So you have $3 \times 3$ choices.

If you distinguish either two yellow balls, $4$ index boxes or both of, you need to multiply $2$ to either one of 3 choices or both of $3$ choices.

{($2$ $\times$ $3$) or $3$} $\times$ {($2$ $\times$ $3$) or $3$} choices.

Now, Case $β { (1, 4) (2, 4) (3, 4)}$ It's almost same way to put two yellow balls into the index though, now if you don't distinguish the 4 index boxes or not, you need to consider the permutation of (red, green, blue), so you have 3 choices for $β{(1, 4) (2, 4) (3, 4)}$ if you distinguished two 4s just multiply 2 to 3 choices. And multiply the permutation $3P3$ and the choices of yellows.

($3$ or $6$) * $3P3$ choices

Finally, Case $γ(4, 4)$. If you don't distinguish two yellows you have 1 choice otherwise 2 choices. And now you need to check the order of (red, green, blue). ($1$ or $2$) * $3P3$ choices.

• @NickPavlov Sorry, thanks for correcting. I was typing from my mobile phone and on a train to the workplace and need to get off a train. I have thought I had saved to reconsider it. I need to fix it. Thanks a lot. – kimi Tanaka Oct 2 '17 at 10:26