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?
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
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
Hence, overall we find:
Therefore in our case we have:
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...
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.
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.