It seems that this is some known problem but I cannot find it. I have m balls and n bins. I would like to generate all possible combinations of putting the balls into the bins including full and empty assignments, i.e., a bin maybe empty or may contain all balls (see the example below).
For example, for m=n=2, I found:
1 x bin 1 contains ball 1, bin 2 contains nothing.
x 1 bin 1 contains nothing, bin 2 contains ball 1.
2 x bin 1 contains ball 2, bin 2 contains nothing.
x 2 bin 1 contains nothing, bin 2 contains ball 2.
1,2 x bin 1 contains balls 1 and 2, bin 2 contains nothing.
x 1,2 bin 1 contains nothing, bin 2 contains balls 1 and 2.
1 2 bin 1 contains ball 1, bin 2 contains ball 2.
2 1 bin 1 contains ball 2, bin 2 contains ball 1.
x x bin 1 contains nothing, bin 2 contains nothing.
How can I generate these combinations in Python (for example)? You can provide a pseudo-code or any programming language you wish.
I start by generating all combinations like
x
1
2
1,2
then I was thinking to assign these combinations to the bins but I could not finish it.
