- #1
elegysix
- 406
- 15
Suppose we have K buckets of differing sizes, so that each bucket can only hold a specific number of rocks, S{k}. Suppose then we are given a specific number of rocks N, which are indistinguishable from one another, and the order of filling doesn't matter. We want to know how many arrangements of N rocks in K buckets of S{k} sizes are possible.
For example
Lets say K is 3, and the sizes are S{1,2,3} = 3, 2, and 1 respectively, and we have N=6 rocks. There is only one possible arrangement in this case because all the buckets have to be filled, and we don't care about the order of filling and the rocks are indistinguishable. ( the arrangement is {3,2,1})Now to make things more complicated, let's say N=5. Then the possible arrangements are
{3,2,0}
{3,1,1}
{2,2,1}
so the answer is 3.
I've been scratching my head trying to figure out a way to calculate the number of arrangements when things get more complicated - say when K = 7, S{1,2,3...}=(10,2,6,10,2,6,10), and N = 16. The number grows very fast with K.
I've written an algorithm that creates all the combinations and then counts them to find the total, but I'm looking for a formula to check that the algorithm is in the ballpark. I'd appreciate any advice.
thanks for your time!
For example
Lets say K is 3, and the sizes are S{1,2,3} = 3, 2, and 1 respectively, and we have N=6 rocks. There is only one possible arrangement in this case because all the buckets have to be filled, and we don't care about the order of filling and the rocks are indistinguishable. ( the arrangement is {3,2,1})Now to make things more complicated, let's say N=5. Then the possible arrangements are
{3,2,0}
{3,1,1}
{2,2,1}
so the answer is 3.
I've been scratching my head trying to figure out a way to calculate the number of arrangements when things get more complicated - say when K = 7, S{1,2,3...}=(10,2,6,10,2,6,10), and N = 16. The number grows very fast with K.
I've written an algorithm that creates all the combinations and then counts them to find the total, but I'm looking for a formula to check that the algorithm is in the ballpark. I'd appreciate any advice.
thanks for your time!