comp.lang.ada
 help / color / mirror / Atom feed
From: bwalker@csl.co.uk (Barrie Walker)
Subject: Re: Friday 13th, try it yourself (was Language Wars..)
Date: 1996/09/25
Date: 1996-09-25T00:00:00+00:00	[thread overview]
Message-ID: <52bdiv$jt0@internet.csl.co.uk> (raw)


In article <R.521pfp$kec@ns.ccsn.edu>, mose@ns.ccsn.edu says...
>
>Reposting article removed by rogue canceller.
>
>Clinton Pierce <cpierce1@ford.com> writes:
>
>>See for yourself if the "Friday the 13th" thing is just a UL.  If you trust
>>UNIX's 'cal' program, and that it does the Right Thing with Leap Years, the
>>Gregorian/Julian switch etc..etc... This Perl script will show you the 
Truth:
>
>   I decided to write a script of my own for Solaris 2.4 and perl
>5.003 which calls cal for 1066 to 1996 and rips out the Fridays.  The
>following is the number of times a particular day of the month falls
>on a Friday.  The results are pretty evenly distributed, i.e. it is an
>Urban Legend.

I think you have caught hold of the wrong end of the stick.

The observation doesn't claim
1 that 13ths have a monopoly on Fridays -
 6ths, 20ths and 27ths fall on just as many Fridays.
2 that the uneven distribution is restricted to Fridays -
 months are more likely to begin (1sts) on Sundays.
3 to work with anything but the current inplementation
 of the Gregorian calendar.

Try the following script and tell me what's wrong with it.
It suggests(?) that the 13th's distribution over the cycle is exactly:
       Sun     Mon     Tue     Wed     Thu     Fri     Sat
13     687     685     685     687     684   * 688     684
Now this is only _one_ (1) more than Sunday or Wednesday gets but "more" it 
certainly is.

#! perl

#start somewhere
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime( 0);

for ($y=0; $y<400; $y++)
{        
  printf "%d\r", $y;
  for ($m=1; $m<=12; $m++)
  {
    $D = &days( $m, $y+1900+$year);
    for ($d=1; $d<=$D; $d++)
    {
      $k{$d,$wday}++;
      $wday++;
      $wday %= 7;
    }
  }
}

sub days
{
  local( $m, $y) = @_;
  return 29 if $m==2 && (!($y%400) || ($y%100) && !($y%4));
  (31,28,31,30,31,30,31,31,30,31,30,31)[$m-1];
}


$D = (reverse sort values %k)[0];
print "$D\n";
for (keys %k)
{
  $k{$_} = '* '.$k{$_} if $k{$_}==$D;
}

printf "%2s %7s %7s %7s %7s %7s %7s %7s\n", "", 
"Sun","Mon","Tue","Wed","Thu","Fri","Sat";
for ($d=1; $d<=31; $d++)
{
  printf "%2s %7s %7s %7s %7s %7s %7s %7s\n", $d, $k{$d,0}, $k{$d,1}, 
$k{$d,2}, $k{$d,3}, $k{$d,4}, $k{$d,5}, $k{$d,6};
}

-- 
Barrie
Edinburgh, Scotland                       http://www.csl.co.uk





             reply	other threads:[~1996-09-25  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-25  0:00 Barrie Walker [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-09-13  0:00 language wars (results 13 September) last posting Roy Gardiner
1996-09-18  0:00 ` Norman H. Cohen
1996-09-19  0:00   ` Andrew Gierth
1996-09-20  0:00 ` Friday 13th, try it yourself (was Language Wars..) Clinton Pierce
1996-09-21  0:00   ` Russell Mosemann
1996-09-25  0:00     ` Barrie Walker
1996-09-26  0:00       ` Jim Shapiro
1996-09-25  0:00     ` Ken Pizzini
1996-09-21  0:00   ` Russell Mosemann
1996-09-23  0:00   ` Matthew D. Healy
1996-09-23  0:00     ` Dik T. Winter
1996-09-25  0:00     ` Paul Gilmartin
1996-09-22  0:00 ` Dr John Stockton
1996-09-23  0:00 ` Dr John Stockton
1996-09-23  0:00 ` Randy MacDonald
1996-09-23  0:00   ` Dik T. Winter
1996-09-25  0:00   ` John Harper
1996-09-25  0:00     ` jupiter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox