Assign the bucket to the number (instead of the number to the bucket), and you have a much easier to comprehend solution. As a sanity check, you will have Yx results.
One approach, with 8 objects in 2 bins, would be to treat it as binary. A digit of '0' in position X would put item X into bucket 0. A digit of '1' in position X would put item X into bucket 1. If you iterate over all of the values for that binary number, you have just iterated over all of the solutions - in this case 256.
00000000 => (87654321), () 00000001 => (8765432), (1) 00000010 => (8765431), (2) 00000011 => (876543), (21) 00000100 => (8765421), (3) ... 11111111 => (), (87654321)
Extrapolate this to any value of X (8 above) and Y (2 above), and you have, I believe, your solution.
Update: Added example data
Update: You could also handle the case where all of the items do not need to be used by assigning a bin Y+1 as a hidden bin.
--MidLifeXis
In reply to Re: x objects in y containers where all objects are used
by MidLifeXis
in thread x objects in y containers where all objects are used
by Ectaris
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |