[LA.pm] next time we need to give away a book...

Benjamin J. Tilly ben_tilly at operamail.com
Mon Mar 7 11:39:51 PST 2005


"Ofer Nave" <ofer at netapt.com> wrote:
> 
> 
> I don't own a PDA.  I do have a laptop, though.
> 
> We could publish Acme::PM::LA, but it's so frivolous.  :)

You mean you don't want to show people how we choose winners?

  sub choose_winner {
    my $total = 0;
    $total += rand(@_) for @_;
    return $_[ $total%@_ ];
  }

> Tell you what.  I'll make sure to bring at least two quarters that are
> hot-swappable, in case the first fails.

That's actually a fun math problem.  Suppose that you have an even
number of people who you want to divide perfectly randomly into
even teams by having people toss quarters.  You want an algorithm
that is both simple to use in practice and is fairly quick about
choosing the teams.  What might a good strategy be?

(With 10 people, there is a simple strategy that has nearly even
odds of achieving the division in one round of coin tosses, and
extremely good odds of finishing it in 2 rounds.)

Cheers,
Ben


More information about the Losangeles-pm mailing list