For example if I have 2 objects and 3 buckets I can distribute the two objects as follows:

2 0 0 0 2 0 0 0 2 1 1 0 1 0 1 0 1 1

Which gives me six unique ways to distribute the objects.

With 3 objects and 3 buckets there are 10 ways to do it. My question is what is the algorithm given X and Y which will give you all unique combinations?

## Comments

kevin_hogan(n,1) = (0,n) = 1

to get (m,n) = C((n-1)+m,m) = ((n-1)+m)!/[m!(n-1)!]

It does have an oddly deja-vu feel to it, doesn't it?

grieveThanks for posting though I can use your algorithm to verify the other algorithm if I figure it out. :)

(Anonymous)grievegrieveNeeds to change to

and

needs to change to