comp.lang.ada
 help / color / mirror / Atom feed
* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-13  0:00 language wars (results 13 September) last posting Roy Gardiner
  1996-09-18  0:00 ` Norman H. Cohen
@ 1996-09-20  0:00 ` Clinton Pierce
  1996-09-21  0:00   ` Russell Mosemann
                     ` (2 more replies)
  1996-09-22  0:00 ` Dr John Stockton
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 16+ messages in thread
From: Clinton Pierce @ 1996-09-20  0:00 UTC (permalink / raw)
  To: Andrew Gierth


Andrew Gierth wrote:
> 
> >>>>> "Norman" == Norman H Cohen <ncohen@watson.ibm.com> writes:
> 
>  > Andrew Gierth wrote:
>  >> The 13th day of the month is more often Friday than any other day
>  >> of the week.
>  Norman> I apologize for the off-topic posting (especially when it is
>  Norman> cross-posted to so many newsgroups, and thus off so many
>  Norman> topics at once), but it should be pointed out, before this
>  Norman> becomes an urban legend, that this "factoid" is patently
>  Norman> false!
> Oh dear. I don't have alt.folklore.urban on my server, or I might take
> this discussion there; in the absence of any obvious other place to
> direct followups to, we will have to stay off-topic for the time
> being. Email might be a good move...
> 
> Skeptics are invited to write a program to do the calculation for
> themselves.
> 

Let's get back on Topic, for comp.lang.perl at least.  

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:


#!/usr/bin/perl4

foreach $year (1066...1996) {
        $FRIDAYS=`cal $year | cut -c20-24,50-53 | grep [0-9]`;
        while($FRIDAYS=~/\d+/g) {
                $DAYOFMONTH{$&}++;
        }
}
foreach(1..31) {
        print "Day of month: $_ Freq: $DAYOFMONTH{$_}\n";
}

Just make sure that your vendor's implementation of 'cal' puts Fridays in the
specified columns.  Use 'cal 1996 | cut -c20-24,50-53' and make sure you just
get Fridays as output.

-- 
----------------------------------------------------------------------o------
    Clinton A. Pierce       |    "If you rush a Miracle Man     |  \ / \ /
    cpierce1@ford.com       |      you get rotten miracles."    |   \ G /
 DCI, Inc. on loan to Ford. | --Miracle Max, The Princess Bride |  / \ / \
------------------------------------------------------------------Freemason--
Geek Code: GCM/GCSd-(++)s+:+a-C++UA++++$UIS+++$UL+++P++++L++E---W++N++w---O
(Revised!)  t++(+++)5+X+R-tv-b+++DI++++G++e+>++h----r+++y+++(--)>y*
I'll be a Speaking Geek at LISA '96.  Catch me on Wed AM, 11:30.  Topic: Igor




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-20  0:00 ` Friday 13th, try it yourself (was Language Wars..) Clinton Pierce
@ 1996-09-21  0:00   ` Russell Mosemann
  1996-09-21  0:00   ` Russell Mosemann
  1996-09-23  0:00   ` Matthew D. Healy
  2 siblings, 0 replies; 16+ messages in thread
From: Russell Mosemann @ 1996-09-21  0:00 UTC (permalink / raw)



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.

Day of month: 1 Freq: 1600
Day of month: 2 Freq: 1594
Day of month: 3 Freq: 1596
Day of month: 4 Freq: 1594
Day of month: 5 Freq: 1593
Day of month: 6 Freq: 1601
Day of month: 7 Freq: 1593
Day of month: 8 Freq: 1600
Day of month: 9 Freq: 1594
Day of month: 10 Freq: 1596
Day of month: 11 Freq: 1594
Day of month: 12 Freq: 1593
Day of month: 13 Freq: 1601
Day of month: 14 Freq: 1593
Day of month: 15 Freq: 1601
Day of month: 16 Freq: 1594
Day of month: 17 Freq: 1596
Day of month: 18 Freq: 1594
Day of month: 19 Freq: 1593
Day of month: 20 Freq: 1601
Day of month: 21 Freq: 1593
Day of month: 22 Freq: 1601
Day of month: 23 Freq: 1594
Day of month: 24 Freq: 1596
Day of month: 25 Freq: 1594
Day of month: 26 Freq: 1593
Day of month: 27 Freq: 1601
Day of month: 28 Freq: 1593
Day of month: 29 Freq: 1499
Day of month: 30 Freq: 1461
Day of month: 31 Freq: 930


    The script is
   

#!/usr/bin/perl

@dom = ();
for ($year = 1066; $year <= 1996; $year++)
{
    open(CAL, "cal $year |");
    $row = <CAL>;                   # Get rid of year
    $row = <CAL>;                   # A blank line
    while($row = <CAL>)
    {
        for ($cols = 0; $cols < 3; $cols++)
        {
            $day = substr($row, 15 + ($cols * 23), 2);
            $dom[$day]++ if $day =~ m/^( |\d)\d$/;
        }
    }
    close(CAL);
}
for ($day = 1; $day <= 31; $day++)
{
    print "Day of month: $day Freq: $dom[$day]\n";
}
-- 
Russell Mosemann     Concordia College      Voice: (402) 643-7445
Computing Center     Seward, NE 68434       Fax:   (402) 643-4073
"If Teflon is non-stick, how do they get it to stick to the pan?"




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-20  0:00 ` Friday 13th, try it yourself (was Language Wars..) Clinton Pierce
  1996-09-21  0:00   ` Russell Mosemann
@ 1996-09-21  0:00   ` Russell Mosemann
  1996-09-25  0:00     ` Barrie Walker
  1996-09-25  0:00     ` Ken Pizzini
  1996-09-23  0:00   ` Matthew D. Healy
  2 siblings, 2 replies; 16+ messages in thread
From: Russell Mosemann @ 1996-09-21  0:00 UTC (permalink / raw)



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.

Day of month: 1 Freq: 1600
Day of month: 2 Freq: 1594
Day of month: 3 Freq: 1596
Day of month: 4 Freq: 1594
Day of month: 5 Freq: 1593
Day of month: 6 Freq: 1601
Day of month: 7 Freq: 1593
Day of month: 8 Freq: 1600
Day of month: 9 Freq: 1594
Day of month: 10 Freq: 1596
Day of month: 11 Freq: 1594
Day of month: 12 Freq: 1593
Day of month: 13 Freq: 1601
Day of month: 14 Freq: 1593
Day of month: 15 Freq: 1601
Day of month: 16 Freq: 1594
Day of month: 17 Freq: 1596
Day of month: 18 Freq: 1594
Day of month: 19 Freq: 1593
Day of month: 20 Freq: 1601
Day of month: 21 Freq: 1593
Day of month: 22 Freq: 1601
Day of month: 23 Freq: 1594
Day of month: 24 Freq: 1596
Day of month: 25 Freq: 1594
Day of month: 26 Freq: 1593
Day of month: 27 Freq: 1601
Day of month: 28 Freq: 1593
Day of month: 29 Freq: 1499
Day of month: 30 Freq: 1461
Day of month: 31 Freq: 930


    The script is
   

#!/usr/bin/perl

@dom = ();
for ($year = 1066; $year <= 1996; $year++)
{
    open(CAL, "cal $year |");
    $row = <CAL>;                   # Get rid of year
    $row = <CAL>;                   # A blank line
    while($row = <CAL>)
    {
        for ($cols = 0; $cols < 3; $cols++)
        {
            $day = substr($row, 15 + ($cols * 23), 2);
            $dom[$day]++ if $day =~ m/^( |\d)\d$/;
        }
    }
    close(CAL);
}
for ($day = 1; $day <= 31; $day++)
{
    print "Day of month: $day Freq: $dom[$day]\n";
}
-- 
Russell Mosemann     Concordia College      Voice: (402) 643-7445
Computing Center     Seward, NE 68434       Fax:   (402) 643-4073
"If Teflon is non-stick, how do they get it to stick to the pan?"




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-13  0:00 language wars (results 13 September) last posting Roy Gardiner
  1996-09-18  0:00 ` Norman H. Cohen
  1996-09-20  0:00 ` Friday 13th, try it yourself (was Language Wars..) Clinton Pierce
@ 1996-09-22  0:00 ` Dr John Stockton
  1996-09-23  0:00 ` Dr John Stockton
  1996-09-23  0:00 ` Randy MacDonald
  4 siblings, 0 replies; 16+ messages in thread
From: Dr John Stockton @ 1996-09-22  0:00 UTC (permalink / raw)



In article <521pfp$kec@ns.ccsn.edu> of Sat, 21 Sep 1996 17:16:25 in
comp.lang.pascal.misc, Russell Mosemann <mose@ns.ccsn.edu> wrote:
>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.
...

You need to test over 400 years, rather than over a more-or-less
arbitrary period, because in the Gregorian calendar the length-of-month
rule repeats every 400 years, and 400 years happens to be an integer
number of weeks.

You will then find that Friday 13th is slightly more common that one
might at first expect.  Authority for this is excellent.


A.D. 2000 is a leap year. After (in the U.K.) 1752, every year divisible
by 4 is leap,
        EXCEPT if it is divisible by 100 but not by 400; so that:

Leap := (Year mod 4 = 0) xor (Year mod 100 = 0) xor (Year mod 400 = 0) ; 

For proof, read any of the following :
RGO, UK : 
  http://www.ast.cam.ac.uk:80/pubinfo/leaflets/leapyear/leapyear.html
  http://www.ast.cam.ac.uk:80/pubinfo/leaflets/2000/2000.html 
  http://www.ast.cam.ac.uk:80/pubinfo/leaflets/calendar/calendar.html 
Claus Tondering :
  ftp://login.dknet.dk/pub/ct/calendar.faq
  ftp://garbo.uwasa.fi/pc/doc-net/calfaq.zip
Prof. Timo Salmi :
  ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
any reputable encyclopaedia; 
or even Windows Calendar, set to Feb 2000.

The Gregorian Calendar repeats every 400 years, which is 146097 days (in
Octal, 435261 days) or exactly 20871 (Octal, 50607) weeks.

BTW, February 29th, in a "century" year, is always Tuesday 29/02/00.


-- 
John Stockton, Surrey, UK.  JRS@merlyn.demon.co.uk  Turnpike v1.12  MIME
    http://www.merlyn.demon.co.uk/




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-13  0:00 language wars (results 13 September) last posting Roy Gardiner
                   ` (3 preceding siblings ...)
  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
  4 siblings, 2 replies; 16+ messages in thread
From: Randy MacDonald @ 1996-09-23  0:00 UTC (permalink / raw)



I've reposted this message from Roger Hui, since his access to
the newsgroup didn't allow for posting to the other groups.
With apologies to the comp.lang.apl folk...

<BEGIN>

Subject: Re: Triskaidekanalysis
       Date: 21 Sep 96 05:35:19 GMT
       From: Roger Hui <Roger.Hui@SYMPATICO.CA>
Organization: UofNB News Gateway, Fredericton, CANADA
  Newsgroups:comp.lang.apl


A more recent and complete leap year rule specifies that years
divisible by 4000 are common (not leap) years.  In J, the following
verb is 1 if the argument is a leap year, and 0 if it is common:

   leapyear=: 0&(~:/ . =) @ (4000 400 100 4&(|/))

In words: Compute the remainder of division by 4000, 400, 100,
and 4.  If the number of 0 remainders is odd, then it is
a leap year; if even, then it is a common year.

The additional 4000-year rule is described in Guy Ottewell's
"The Astronomical Companion", 1979, Furman University, Greenville,
SC, USA, Telephone (803) 294-2208.  The reason for having the rule
is to bring the average calendar year closer to the tropical year
(within one day in 20000 years):

   1460969 days % 4000 years = 365.24225 days/year  (4000 year rule)
   146097  days % 400  years = 365.2425  days/year  (400  year rule)

Therefore, to determine the distribution of the 13-th day over
the days of the week, it is necessary to consider not just a
400 year cycle, but a 28000 year cycle.  (Actually the first
should be a 2800 year cycle, with a short cut to 400 years made
possible by the fact that 146097 is divisible by 7.)

The analysis can be done in J as follows:

   p=: 31 28,10$5$31 30       NB. days in month in common years
   q=: 31 29,10$5$31 30       NB. days in month in leap   years
   +/,(leapyear i.4000){p,:q  NB. # days in 4000 years
1460969

   y=: i.28000                NB. year numbers from 0 to 27999.

   d=: (leapyear y){p,:q      NB. # of days in each month in y
   $d                         NB. d is a 28000 by 12 matrix
28000 12
   5{.d                       NB. first 5 rows of d
31 28 31 30 31 30 31 31 30 31 30 31
31 28 31 30 31 30 31 31 30 31 30 31
31 28 31 30 31 30 31 31 30 31 30 31
31 28 31 30 31 30 31 31 30 31 30 31
31 29 31 30 31 30 31 31 30 31 30 31

   w=: 7| +/\ ,d              NB. day-of-week of every 13-th day of
month
   20 {. w                    NB. first 20 entries in w
3 3 6 1 4 6 2 5 0 3 5 1 4 4 0 2 5 0 3 6

   t=: /:~ (~.w) ,. #/.~ w    NB. sorted table of day-of-week, #
occurrences
   t
0 48000
1 48000
2 48000
3 48000
4 48000
5 48000
6 48000

The next example shows that a 4000-year cycle exhibits uneven
distribution.
Since the number of days in 4000 years (1460969) is not divisible by 7,
the unevenness is smoothed out when the cycle is lengthen by a factor of
7,
as above.

   /:~ (~.w) ,. #/.~ w=: 7 | +/\ , (leapyear i.4000){p,:q
0 6880
1 6840
2 6869
3 6851
4 6850
5 6870
6 6840

<END>




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-23  0:00 ` Randy MacDonald
@ 1996-09-23  0:00   ` Dik T. Winter
  1996-09-25  0:00   ` John Harper
  1 sibling, 0 replies; 16+ messages in thread
From: Dik T. Winter @ 1996-09-23  0:00 UTC (permalink / raw)



In article <32462521.76DD@godin.on.ca> randy@godin.on.ca writes:
 > The additional 4000-year rule is described in Guy Ottewell's
 > "The Astronomical Companion", 1979, Furman University, Greenville,
 > SC, USA, Telephone (803) 294-2208.

That it is described there does not make it a rule.  It has been a
proposal by the American Astronomical Society, but it *never*
made it to a rule (although some older editions of the Encyclopedia
Brittanica mention it as a rule).
-- 
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland, +31205924098
home: bovenover 215, 1025 jn  amsterdam, nederland; http://www.cwi.nl/~dik/




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-20  0:00 ` Friday 13th, try it yourself (was Language Wars..) Clinton Pierce
  1996-09-21  0:00   ` Russell Mosemann
  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
  2 siblings, 2 replies; 16+ messages in thread
From: Matthew D. Healy @ 1996-09-23  0:00 UTC (permalink / raw)



In article <3242D1EB.3F54@ford.com>, Clinton Pierce <cpierce1@ford.com> wrote:

> 
> 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:
> 

But this will be modulo your country, because different countries did
the Julian/Gregorian change in different years, ranging from the sixteenth
to the twentieth* centuries.  Most flavors of Unix cal do it when the
British and their colonies did.  Dunno whether customers in, say,
Sweden can get one where cal works for their country.

PS: About six months ago when I entered a thread on different dates of
Julian/Gregorian switching in another newsgroup, I got email from an
astronomer somewhere in Europe who told me his country (forget which
one) did a _really_ strange number on this: instead of stepping in
a single year, they had half a century with no leap years until
they were in sync with the Gregorian calendar!  Stick _that_ in cal's
pipe and smoke it!

*Yes, twentieth.  Until the last Tsar fell, Russia was still on the
Julian calendar.  That's why the "October revolution" took place in
November.

---------
Matthew.Healy@yale.edu
http://paella.med.yale.edu/~healy
"Any content-based regulation of the Internet could burn down the
global village to roast the pig."  -- Judge Dalzell, on the CDA




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-23  0:00   ` Matthew D. Healy
@ 1996-09-23  0:00     ` Dik T. Winter
  1996-09-25  0:00     ` Paul Gilmartin
  1 sibling, 0 replies; 16+ messages in thread
From: Dik T. Winter @ 1996-09-23  0:00 UTC (permalink / raw)



In article <Matthew.Healy-2309960924350001@pudding.med.yale.edu> Matthew.Healy@yale.edu (Matthew D. Healy) writes:
 > PS: About six months ago when I entered a thread on different dates of
 > Julian/Gregorian switching in another newsgroup, I got email from an
 > astronomer somewhere in Europe who told me his country (forget which
 > one) did a _really_ strange number on this: instead of stepping in
 > a single year, they had half a century with no leap years until
 > they were in sync with the Gregorian calendar!

From Sweden probably and told wrong.  It was the intention that starting
1700 they would omit leap years until they were in sync with the Gregorian
calendar.  So 1700 was not a leap year.  But they forgot about that or
something and they made 1704 and 1708 leap years, so they did not gain
on the Gregorian calendar and were one day out of sync with the Julian
calendar.  In 1712 they got back in sync with Julian by adding a
February 30.  They finally changed later that century (1768 if I remember
right).

But what this is doing in all those newsgroups...
-- 
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland, +31205924098
home: bovenover 215, 1025 jn  amsterdam, nederland; http://www.cwi.nl/~dik/




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-13  0:00 language wars (results 13 September) last posting Roy Gardiner
                   ` (2 preceding siblings ...)
  1996-09-22  0:00 ` Dr John Stockton
@ 1996-09-23  0:00 ` Dr John Stockton
  1996-09-23  0:00 ` Randy MacDonald
  4 siblings, 0 replies; 16+ messages in thread
From: Dr John Stockton @ 1996-09-23  0:00 UTC (permalink / raw)



In article <32462521.76DD@godin.on.ca> of Mon, 23 Sep 1996 01:50:25 in
comp.lang.pascal.misc, Randy MacDonald <randy@godin.on.ca> wrote:
>I've reposted this message from Roger Hui, since his access to
>the newsgroup didn't allow for posting to the other groups.
>With apologies to the comp.lang.apl folk...
>
> ...
>
>A more recent and complete leap year rule specifies that years
>divisible by 4000 are common (not leap) years. 
> ...

That is a reasonable proposal - though AFAIR 3200 might be better than
4000 - but it has NO AUTHORITY.

The present calendar has a 400-year cycle.  Links to some references are
via the URL below.

-- 
John Stockton, Surrey, UK.  JRS@merlyn.demon.co.uk  Turnpike v1.12  MIME
    http://www.merlyn.demon.co.uk/




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
@ 1996-09-25  0:00 Barrie Walker
  0 siblings, 0 replies; 16+ messages in thread
From: Barrie Walker @ 1996-09-25  0:00 UTC (permalink / 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





^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  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
  1 sibling, 1 reply; 16+ messages in thread
From: John Harper @ 1996-09-25  0:00 UTC (permalink / raw)



In article <32462521.76DD@godin.on.ca>,
Randy MacDonald  <randy@godin.on.ca> wrote:
>       From: Roger Hui <Roger.Hui@SYMPATICO.CA>
>Organization: UofNB News Gateway, Fredericton, CANADA
>  Newsgroups:comp.lang.apl
>
>A more recent and complete leap year rule specifies that years
>divisible by 4000 are common (not leap) years. 

No point considering this one yet. Calendars are legal matters (they
determine when payments are due, when public holidays are, and so on)
Unless and until some government incorporates the 4000-year rule in its
laws, we may as well go on using the Gregorian rule (except of course
that there is a Greek? rule that has a 2-exceptions-every-900-years
rule instead of 1-exception-every-400-years.

John Harper Mathematics Dept. Victoria University Wellington New Zealand




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-25  0:00   ` John Harper
@ 1996-09-25  0:00     ` jupiter
  0 siblings, 0 replies; 16+ messages in thread
From: jupiter @ 1996-09-25  0:00 UTC (permalink / raw)



In <52a2d6$4v7@totara.its.vuw.ac.nz>, harper@kauri.vuw.ac.nz (John Harper) writes:
>Randy MacDonald  <randy@godin.on.ca> wrote:
>>A more recent and complete leap year rule specifies that years
>>divisible by 4000 are common (not leap) years. 
>
>No point considering this one yet. Calendars are legal matters (they
>determine when payments are due, when public holidays are, and so on)
>Unless and until some government incorporates the 4000-year rule in its
>laws, we may as well go on using the Gregorian rule

Isn't it true that the Soviet Union adopted the 4000-year rule legally?
I've read about it in one of Asimov's papers.
How is the current situation in Russia?
I assume they wouldn't have bothered to revert to the strictly 
Gregorian calendar, specially since their version gets rid of that 
3 days displacement every 10000 years.

Manuel Alfonseca, Universidad Autonoma Madrid




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  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
  1 sibling, 1 reply; 16+ messages in thread
From: Barrie Walker @ 1996-09-25  0:00 UTC (permalink / 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





^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-21  0:00   ` Russell Mosemann
  1996-09-25  0:00     ` Barrie Walker
@ 1996-09-25  0:00     ` Ken Pizzini
  1 sibling, 0 replies; 16+ messages in thread
From: Ken Pizzini @ 1996-09-25  0:00 UTC (permalink / raw)



In article <R.521pfp$kec@ns.ccsn.edu>,
Russell Mosemann <mose@ns.ccsn.edu> wrote:
>   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.

Try again, avoiding years befor 1752.  The cal program on Solaris
uses the Julian calender for years before 1752, the Gregorian
calendar for years after, and the calendar that England and
her colonies used for 1752 itself.  Under the Julian calendar
the 13th of a month will be equidistributed among each of the
days of the week, but under the Gregorian calendar you will find
that some days fall on the 13th more frequently than others
over a 400 year cycle.  (Note that any pair of dates on the
Gregorian calendar that are exactly 400 years apart will
fall on the same day of the week.)

		--Ken Pizzini




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-23  0:00   ` Matthew D. Healy
  1996-09-23  0:00     ` Dik T. Winter
@ 1996-09-25  0:00     ` Paul Gilmartin
  1 sibling, 0 replies; 16+ messages in thread
From: Paul Gilmartin @ 1996-09-25  0:00 UTC (permalink / raw)



Matthew D. Healy (Matthew.Healy@yale.edu) wrote:

: PS: About six months ago when I entered a thread on different dates of
: Julian/Gregorian switching in another newsgroup, I got email from an
: astronomer somewhere in Europe who told me his country (forget which

(quite likely Paul Schlyter :-)

: one) did a _really_ strange number on this: instead of stepping in
: a single year, they had half a century with no leap years until
: they were in sync with the Gregorian calendar!  Stick _that_ in cal's
: pipe and smoke it!

From:    
   Linkname: Calendar FAQ
        URL: ftp://login.dknet.dk/pub/ct/calendar.faq

        This document is Copyright (C) 1996 by Claus Tondering.
        E-mail: ct@login.dknet.dk.

Sweden has a curious history. Sweden decided to make a gradual change
from the Julian to the Gregorian calendar. By dropping every leap year
from 1700 through 1740 the eleven superfluous days would be omitted  
and from 1 Mar 1740 they would be in sync with the Gregorian 
calendar. (But in the meantime they would be in sync with nobody!)   
 
So 1700 (which should have been a leap year in the Julian calendar)  
was not a leap year in Sweden. However, by mistake 1704 and 1708
became leap years. This left Sweden out of synchronisation with both
the Julian and the Gregorian world, so they decided to go *back* to
the Julian calendar. In order to do this, they inserted an extra day
in 1712, making that year a double leap year! So in 1712, February had
30 days in Sweden.        

Later, in 1753 Sweden changed to the Gregorian calendar by dropping 11
days like everyone else.

--gil




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Friday 13th, try it yourself (was Language Wars..)
  1996-09-25  0:00     ` Barrie Walker
@ 1996-09-26  0:00       ` Jim Shapiro
  0 siblings, 0 replies; 16+ messages in thread
From: Jim Shapiro @ 1996-09-26  0:00 UTC (permalink / raw)



Barrie Walker (bwalker@csl.co.uk) wrote:
: 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.

[well written Perl code deleted]

I ran your program and got the same results, then I realized that this whole
argument is silly.  Suppose, for the sake of argument and with no loss in
in generality, we look at the day of the week the first of each month falls
on.  If January starts on say a Monday, the days for the remaining 11 months
depend only on the number of days in each month.  If all the months were 28
days (or any number that is congruent to 0 (mod 7) then _all_ the firsts would
be on Monday!  Given the odd ball number of days in each month (a number which
even changes with the year, for some years) the firsts of each month will
be divided among the days of the week in some _deterministic_ fashion.  Over
a 400 year interval it does not come out exactly evenly distributed.  That is
all there is to it.  Why does anyone think that firsts or thirteenths or any
day should be equally likely to be on any one weekday over any other in the
first place?

I guess it is a little counterintuitive, sort of like the famous birthday
problem, one which I will not introduce to keep the thread length in check.

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

--
Hope this helps,
Jim Shapiro




^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~1996-09-26  0:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-25  0:00 Friday 13th, try it yourself (was Language Wars..) Barrie Walker
  -- 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-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-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

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