...that 5 of Andrew's 212 friends share a birthday.
#!/usr/bin/perl
#monte carlo calculation on Andrew's Birthday question.
# In short, this code allows a general test of the question:
# "if I have x friends, what are the chances that any y of
# them share a birthday?" It does so using Monte Carlo technique.
# runs should be set high (at least 1000, maybe higher) to give a
# good answer. I don't know what gives good confidence here.
# init a few things. bdaymatches is how many friends share one birthday.
use constant friends => 212;
use constant runs => 10000;
use constant bdaymatches => 5;
$foundmatches = 0;
# this loop calls yeartally once per run, adding each run to the array of
# runs called fullrun.
for ($i = 1; $i <= runs; $i++)
{
@temp = &yeartally;
$fullrun[$i] = [ @temp ];
#print "@temp\n";
# printf "THIS IS A YEAR BREAK \n";
}
#debug printing of the array: