Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: Sports Team allocation

by cacharbe (Curate)
on Jul 19, 2002 at 11:55 UTC ( [id://183196]=note: print w/replies, xml ) Need Help??


in reply to Re: Sports Team allocation
in thread Sports Team allocation

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.

C-.

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-25 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found