in reply to Re: x objects in y containers where all objects are used
in thread x objects in y containers where all objects are used

I'm not sure I understand the situation the OP is addressing or facing. Even after looking at the various responses and the OP's comments, I'm still not sure I'm understanding.

But like toolic, I would suggest that if the OP hasn't already done so, looking into and considering CPAN modules. In particular I'd suggest looking in the List:: and Set:: modules of CPAN.

I have been looking in CPAN for some module to do what I *think* is similar to what the OP is seeking except that my 'bags' had limited capacity whereas. If I understand the thread for this OP's question, the OP doesn't have that limitation. Anyway, I came upon the module Set::Bag which solved my particular problem. I have found that the List:: modules and the Set:: modules have a pretty rich set of tools to handle a wide variety of Power Set, binning, permutation and combinatorial problems. I would offer that it's worth looking at the modules in those two areas (List:: and Set:: ).

Unfortunately, except for Set::Bag, I really don't have any experience with any of the rest. I just saw them as I was trying to find the solution to my particular problem and once I found Set::Bag, I had no additional need to learn more.

ack Albuquerque, NM
  • Comment on Re^2: x objects in y containers where all objects are used

Replies are listed 'Best First'.
Re^3: x objects in y containers where all objects are used
by MidLifeXis (Monsignor) on Nov 06, 2009 at 18:59 UTC

    The OP problem is easier if you think of it as assigning bins to items, and not as assigning items to bins. Each item MUST have one and only one bin. If you switch your thinking to assign on value in set Y to each of the items in X, then it becomes a much more clear problem.

    Each item in X can be assigned exactly one of the values in Y. It is now the same class of a problem as counting in binary.

    --MidLifeXis

      Thanks. Now I get it. As sometimes bites me, it is always constructive to step back and see if there are other ways to look at a problem. Your advice is right on...it *is* much easier to visualize the OP's challenge from the perspective you suggest.

      ack Albuquerque, NM