"Seth Brundle" <> wrote:
> Say I have a hash with peoples names and a quality score, like their free
> throw percentage.
>
> Mathematically what is the most accurate way to divide the list into the
> two most balanced teams?
Mathematically, enumerate all possible sets of teams, compute the
balancedness of each, and take the one with the most balancedness. There
are various combinatoric modules and sample-code for Perl, but which one
you want probably depends on what exactly constitutes a legal pair of
teams.1
> Obviously you could do something simple like alternate in descending
> order, but this isnt guaranteed to produce the most accurate result.
It is not guaranteed to produce the *optimal* result. Accuracy probably
doesn't enter into it.
>
> Ideally, I would like to be able to balance based on the mean, median, or
> both.
Do both teams have to be the same size? If so, then balancing on mean is
the same as balancing on sum, right? That sounds like a variant of the
well-known bin-packing or knap-sack problems. For the median, that depends
strongly on whether the teams have to be divided equally, and also on
whether the number on each team is going to be odd or even, and on how you
define median in the case of even-membered teams.
>
> Code isnt necessary but of course appreciated - but if you have a link to
> the fundementals of solving such a problem thats fine to - I want to
> learn to do it for myself.
knap-sack and bin-packing are very widely discussed fundamentals. Google
on those terms, you will find more than you care for on them.
Xho
--
--------------------
http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB