I have $n$ non-unique elements, and I have $k$ unordered buckets that can hold anywhere from $0$ to $c$ elements, such that $c * k \geq n$. I would like to find all possible combinations.
For example, given $n=10$, $k=4$, and $c=4$, there are 7 possible distributions:
- 3322
- 3331
- 4222
- 4321
- 4330
- 4411
- 4420
where "3322", for example, means that two buckets have three elements each and the other two buckets have two elements each.
Another way to look at it, is that I want to find unique combinations of $k$ numbers less than or equal to $c$ such that their sum is equal to $n$.
Ideally I'd like an algorithm to be able to generate a list of all acceptable combinations, but knowing a formula for finding the number of combinations given arbitrary $n$, $k$, and $c$ would be helpful. Other answers generally assume buckets have to have a minimum capacity of 1, or they deal with unique elements to some degree, which are not the case here.