Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say, I have 4 yellow and 5 blue balls. How do I calculate in how many different orders I can place them? And what if I also have 3 red balls?

share|cite|improve this question
maybe a title more clear could be "In how many different ways can I sort balls of two different colors" – mau Jul 22 '10 at 7:37
So, you're asking for how many unique ways you can sort them? And swapping two red balls in a certain arrangement doesn't count as a unique new sorting. – Justin L. Jul 22 '10 at 7:38
@Justin L., That's probably a fair assumption, yeah. – Noldorin Jul 22 '10 at 7:53
up vote 8 down vote accepted

This is a standard problem involving the combinations of sets, though perhaps not very obvious intuitively.

Firstly consider the number of ways you can rearrange the entire set of balls, counting each ball as indepndent (effectively ignoring colours for now). This is simply (4 + 5)! = 9!, since the 1st ball can be any of the 9, the 2nd can be any of the remaining 8, and so on.

Then we calculate how many different ways the yellow balls can be arranged within themselves, since for the purpose of this problem they are considered equivalent. The number of combinations is of course 4!; similarly, for the blue balls the number is 5!.

Hence, overall we find:

total no. of arrangements = number of arrangements of all balls / (number of arrangements of yellow balls * number of arrangements of blue balls)

Therefore in our case we have:

total no. of arrangements = 9! / (5! * 4!) = 126

I'm sure you can see how this can be easily extended if we also have 3 red balls too. (Hint: the total changes and we have another multiple of identical arrangements to account for.)

Hope that helps...

share|cite|improve this answer

The case of two colors is simple: if you have m yellow balls and n blue ones you only need to choose m positions among (m+n) possibilities, that is (m+n)!/(m!·n!). The other balls' positions are automatically set up.

share|cite|improve this answer

For some reason I find it easier to think in terms of letters of a word being rearranged, and your problem is equivalent to asking how many permutations there are of the word YYYYBBBBB.

The formula for counting permutations of words with repeated letters (whose reasoning has been described by Noldorin) gives us the correct answer of 9!/(4!5!) = 126.

share|cite|improve this answer

Your Answer


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.