# Permutations with groups of different sizes

Hi I am unable to find any resources online about my current problem.

What I have is a bowl with $$x$$ balls and I want to know how many orders are possible when I pull out $$k$$ balls.
My problem is that there are different ball colors and not all of those colors have the same amount of balls. So for instance I could have a bowl $$B$$ with $$5$$ balls $$B=\{r, r, g, g, b\}$$

This is where I am stuck, I known that the number of permutations for $$B$$ is $$5!$$ if you don't think of balls with the same color as being the same, however I am only interested in the order of the colors.
If you would swap the position of 2 same colored balls I want both orders to be the same permutation.

So what I have come up with is this:
$$\dfrac{x!}{(c_1!*c_2!*...c_n!)}$$
I am still not quite sure if this is correct, however ProjectEuler (#15) accepted my solution.
Where I am still in the dark is what I should do if I don't want to pull out all balls. So instead of taking all the $$x$$ balls out of the bowl I only want to take $$n$$ how can I get the number of permutations for those orders?

I would also appreciate if someone could tell me if there is a better way to call this problem since the google results I got when searching for "Permutations with groups of different sizes" did not really address my problem.

If I understand in a correct way your peoblem shortly seems like "Suppose we have $$N$$ balls with $$c_i$$ many of them same color and $$c_1+\ldots +c_m=N$$. How many different ways we can put them side by side ". Then this one is exatly repetitive permutation. And you want to see its proof. Some of them right here What is the proof of permutations of similar objects? in addition I can say something in intuitive way. Think the high school problem. "A mom and a dad with 3 kids want to get a photo side by side. How many different way can they do it under the condition mom and dad will be together" For answer we say $$4!.2!$$ and the reason is first we suppose mom and dad just one people and we get $$4!$$, then we consider they can change their space among themselves and get $$2!$$ and multiply with $$4!$$. Now turn back your problem supoose none of them has same color. Then we have $$N!$$ right!. But $$c_i$$ of them has same color, it means changing of the $$c_i$$ of balls in among themselves (totally $$c_i!$$) is not important. (In the high school problem it was important and we multiplied). So we need to divide the $$N!$$ with $$c_i!$$.
In addition If we add "If we take just $$M$$ of them from $$N$$ many balls while $$M\leq N$$ then how many $$\ldots$$" in your problem. That time we can think like we take or move out $$r_i$$ many in $$c_i$$'s while $$r_1+\ldots+r_m=N-M$$ and $$r_i\leq c_i$$ then the answer must be
$$\sum_{ r_1+\ldots+r_m=N-M \\ r_i\leq c_i}\dfrac{M!}{(c_1-r_1)!.(c_2-r_2)\ldots (c_m-r_m)!}$$
• Ok Thanks I got it now. But what do I have to do now if I have the same 5 balls but now instead of taking them all I only want 4, or generally any number $t$? – jaklh Oct 12 '18 at 17:55