I have m "slots" with indivual capacity c_m. Now I want to distribute a certain amount of integer k to those m slots without exceeding their capacity c_m. Such that every slot has a certain "contingent" between 0 and c_m and the sum of all contingents equal k.
Now I want to generate all the combinations, without duplicates and in a most efficient way. Obviously I don't need to differntiate between coningents of same value. The slots have an identity though, so that their order matters.
I hope that describes my problem understandable (no homework btw).
My guess is that the best way would be to generate one trivial solution and then generate the next combination out of the previous one. I would then restrict the difference between the new and the previous combination to at most 2, for subtracting 1 at one slot and adding 1 to another slot. From that I only need a way to identify duplicates when I'm about to generate one. But I'm open for other ideas, too.