[LA.pm] The odds of finger games

Erick Calder e at arix.com
Wed Mar 5 15:54:51 CST 2003


I had a great time guys.  I really wanted that mousepad!! but I figured Ask
could make better use of it than I since I mostly work on a laptop.

btw, the http://pm.org isn't defined... I have to http://www.pm.org

-----Original Message-----
From: losangeles-pm-admin at mail.pm.org
[mailto:losangeles-pm-admin at mail.pm.org]On Behalf Of Robert Spier
Sent: Wednesday, March 05, 2003 1:29 PM
To: losangeles-pm at mail.pm.org
Cc: Peter Scott
Subject: [LA.pm] The odds of finger games

Apparently the finger circle thingy we did at the very fun meeting
last night actually is fair, as long as you assume that everyones hand
is a perfect RNG.

(Of course, you can't assume that every person is a perfect random
number generator... but that's a different discussion.)

This little program simulates every possible possible combination of
five fingers and six people, builds up the sum, and then does the
mods.  The curve on the raw sums is just as we expected, peaking at
15... but once mod-ded it all balances out:

0: 7776
1: 7776
2: 7776
3: 7776
4: 7776
5: 7776

use strict;
use warnings;
use Set::CrossProduct;
my $people = 6;
my $fingers = 5;
my $hand = [0..$fingers];
my $it = Set::CrossProduct->new( [($hand)x $people] );
my %sums = ();
my %modsums = ();

while (my $tuple = $it->get) {
  my $t;
  $t += $_ for @$tuple;
  $sums{$t}++;
  $modsums{$t%$people}++;
}

# Output non-mod-ed values (sum of all fingers)
#print "$_: $sums{$_}\n"
#  for (sort {$a <=> $b} keys %sums);

# Output mod-ed values, i.e. "people"
print "$_: $modsums{$_}\n"
  for (sort {$a <=> $b} keys %modsums);



-R
_______________________________________________
Losangeles-pm mailing list
Losangeles-pm at mail.pm.org
http://mail.pm.org/mailman/listinfo/losangeles-pm




More information about the Losangeles-pm mailing list