Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Sports Team allocation

by thealienz1 (Pilgrim)
on Jul 19, 2002 at 03:44 UTC ( #183116=note: print w/replies, xml ) Need Help??

in reply to Sports Team allocation

Some people asked me to give an example. The example I was give to work with was 48 people that needed to be divided up into 8 teams, which means 6 people per team. And then there needed to be 3 sets of these 8 teams, so that the people in the first set did not have the same people on their team in the second and third set.

Replies are listed 'Best First'.
Re: Re: Sports Team allocation
by cacharbe (Curate) on Jul 19, 2002 at 11:55 UTC
    The first step would be to find the number of choices. In this case, we would use a combination rather than a permutation, since the order of our choices is irrelevant. We can find this number with:

    sub choose { my ($n, $k) = @_; my ($result, $j) = (1, 1); return 0 if $k > $n || $k < 0; $k = ($n - $k) if ($n - $k) < $k; while ( $j <= $k ) { $result *= $n--; $result /= $j++; } return $result; } my $people = 48; my $teams = 8; my $seasons = 3; print choose($people, ($people/$teams));
    In your case, there are a possible 12271512 different team combinations, but this isn't the complete answer yet. You'll actually want to generate these teams such that you can find which of them have repeated couples.

    I've got some coding for work to do, but I'll crunch on this throughout the day and update as I can, barring someone else having more freetime and posting a solution before I do.


    Update: Or you could completely ignore my intellectually overstimulated response and go with what Abigail-II suggested, which will actually solve the problem. Thanks for the instruction.

    Flex the Geek

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2019-10-19 21:59 GMT
Find Nodes?
    Voting Booth?