Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: x objects in y containers where all objects are used

by toolic (Bishop)
on Nov 06, 2009 at 14:09 UTC ( [id://805489]=note: print w/replies, xml ) Need Help??


in reply to x objects in y containers where all objects are used

I googled 'cpan combination' and found Math::Combinatorics.

Then, I googled 'cpan permute' and found Algorithm::Permute.

I have no idea if they will help you, but they seem promising.

  • Comment on Re: x objects in y containers where all objects are used

Replies are listed 'Best First'.
Re^2: x objects in y containers where all objects are used
by ack (Deacon) on Nov 06, 2009 at 18:43 UTC

    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

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://805489]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-20 07:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found