Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Permutation of groups

by blokhead (Monsignor)
on Nov 20, 2006 at 15:05 UTC ( [id://585069]=note: print w/replies, xml ) Need Help??


in reply to Permutation of groups

Actually this looks more like set partitions than combinations to me. You are splitting up a set into smaller subsets, and order and size of subsets doesn't matter. There is some sample code for a set partition iterator in one of my nodes Re: Generator of integer partitionts of n for starters, and plenty of other places too, probably, if you super search with that term.

blokhead

Replies are listed 'Best First'.
Re^2: Permutation of groups
by Limbic~Region (Chancellor) on Nov 20, 2006 at 16:58 UTC
    blokhead,
    I can see your point of view too. I admit that I focused on:

    In fact, I want to get all possible teams:

    While my solution addresses the above statement in isolation, taken in context with the rest of the post it is likely lacking. For instance:

    • For any given game, do all teams need to have the same number of players?
    • For any given game, can a player participate in more than one team?
    • For any given game, do all players need to play or can they "sit out"?

    I am not sure how much of your code addresses those points either but I am pretty sure it misses how to convert a team to a "number" and its reciprocal. Any ideas on that front?

    Cheers - L~R

      Specifically for a given partitioning ever person must belong to exactly one team.

      Teams do not have to be of the same size.

      eg For three people: 1. A B C 2. AB C 3. A BC 4. AC B 5. ABC

        tomazos,
        Assuming it does the right thing, you are going to want to use the integer partitioning code blokhead refers to above and the binary counting I explained. You will not have a contigous range of team reference numbers but they will be guaranteed to be unique and will never be higher than 2 ** $num_of_people.

        If I find the time tonight or tomorrow, I will code this for you. If you end up coding it on your own, please post so others can benefit and I won't bother.

        Cheers - L~R

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2025-07-16 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.