#!/usr/bin/perl


$trials = 1000000;
$ec = 0;
$pp = 0;
$denom = 2.224;

for (0..$trials) {

if ($_ % 1000 == 0) {
$wah = $ec - $pp;
print "$_ trials run; ec is $ec, pp is $pp : $wah \n";
 
}

@monkeys = ();
for (0..119) {
  push @monkeys, (int(rand($denom)) < 1 ? 0 : 1);
}

$votes = 0;
@evotes = ();
for (0..$#monkeys) {
  $votes += $monkeys[$_];
  $evotes[int($_/11)] += $monkeys[$_];
}

$pp ++ if ($votes == 60);

$bl = 0;

for (@evotes) {
  $bl++ if ($_ >= 6);
}

$ec ++ if ($bl == 5 and $evotes[10] == 5);

}

print "ec matters $ec\n";
print "pp matters $pp\n";
