From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7be1,be6b7e036aa9236c X-Google-Attributes: gidf7be1,public X-Google-Thread: 11390f,be6b7e036aa9236c X-Google-Attributes: gid11390f,public X-Google-Thread: 101deb,be6b7e036aa9236c X-Google-Attributes: gid101deb,public X-Google-Thread: 1014db,be6b7e036aa9236c X-Google-Attributes: gid1014db,public X-Google-Thread: 1164ba,be6b7e036aa9236c X-Google-Attributes: gid1164ba,public X-Google-Thread: 1094ba,be6b7e036aa9236c X-Google-Attributes: gid1094ba,public X-Google-Thread: fa0ae,be6b7e036aa9236c X-Google-Attributes: gidfa0ae,public X-Google-Thread: 103376,be6b7e036aa9236c X-Google-Attributes: gid103376,public From: andrewg@microlise.co.uk (Andrew Gierth) Subject: Re: language wars (results 13 September) last posting Date: 1996/09/24 Message-ID: #1/1 X-Deja-AN: 184910697 distribution: inet x-geek: (V3.1) x-nntp-posting-host: microl.demon.co.uk references: <51bv60$8d@pheidippides.axion.bt.co.uk> cc: Ken Pizzini x-mayan-date: Long count = 12.19.3.9.5; tzolkin = 10 Chicchan; haab = 8 Chen organization: Microlise Engineering Ltd. x-attribution: AG newsgroups: comp.lang.ada,comp.lang.apl,comp.lang.basic,comp.lang.c,comp.lang.fortran,comp.lang.perl.misc,comp.lang.pl1,comp.lang.rexx,comp.lang.pascal.misc,comp.lang.smalltalk Date: 1996-09-24T00:00:00+00:00 List-Id: >>>>> "Ken" == Ken Pizzini writes: > In article <32414A27.14E@cat.com>, Daniel J. Long wrote: >> Ok, here is my program, written in Smalltalk, to calculate the >> distribution >> of Friday the 13ths for a 2800 year period from 1996 to 4795. BTW, >> Friday did >> turn out to be the most likely 13th. [code snipped] >> >> Result: Mon Tues Wed Thur Fri Sat Sun >> #(4795 4795 4809 4788 4816 4788 4809) Ken> What is the impentation of Date and/or weekdayIndex? I think Ken> this shows that at least one of them has a bug... Why do you say that? OK, so my smalltalk is nonexistent, but the code given looks ok, and here for your delectation is my version in Emacs Lisp, and my results: (require 'calendar) (defun day-of-13th (month year) (calendar-day-of-week (list month 13 year))) (defun d13-one-year (v year) (mapcar (lambda (month) (let ((day (day-of-13th month year))) (aset v day (1+ (aref v day))))) '(1 2 3 4 5 6 7 8 9 10 11 12)) v) (defun d13-range (first count) (let ((v (vector 0 0 0 0 0 0 0)) (y first) (lim (+ first count))) (while (< y lim) (setq v (d13-one-year v y)) (setq y (1+ y))) v)) (d13-range 1996 2800) [4809 4795 4795 4809 4788 4816 4788] Note - this code uses 0=Sunday. So, my results agree with Mr. Long's. Incidentally, for the curious, I first came across this obscure fact in an exercise in a book (exactly *which* book I forget, but I vaguely recall that it might have been Richards (?) & Whitby-Strevens (sp?) book on BCPL). The exercise simply said "Write a program to prove that the 13th falls more often on Friday than any other day of the week". So I did (but not in BCPL). -- Andrew Gierth (andrewg@microlise.co.uk) "Ceterum censeo Microsoftam delendam esse" - Alain Knaff in nanam