Posts

Showing posts from 2011

Unix cal program for September 1752

//calendar for September 1752 % cal 9 1752 September 1752 Su Mo Tu We Th Fr Sa 1 2 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Prepare to Meet Thy Doomsday

I wrote an article for Scientific American regarding the Doomsday algorithm. " What Day is Doomsday ? How to Mentally Calculate the Day of the Week for Any Date" special thanks to John Matson for the editorial work.

Sakamoto's Algorithm

Tomohiko Sakamoto came up with a terse program for calculating the day of the week in 1993. His code was written in the C language. The non-portable code goes like this: int dayofweek(unsigned int y, unsigned int m, unsigned int d) { y -= m < 3; return (y + y/4 - y/100 + y/400 + "-bed=pen+mad."[m] + d) % 7; } Here is the portable version: int dayofweek(int y, int m, int d) { static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; y -= m < 3; return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7; }

Negative Space Font

Image
"Doomsday Algorithm" in negative space font

Doomsday Timeline

by the doomsayers The Doomsday Algorithm was first introduced in 1973. Over the years, it has undergone many refinements and improvements. The ultimate goal is to make the algorithm easy to calculate mentally in addition to being easy to remember. Here is a timeline of important modifications to the Doomsday algorithm. Please email spectralfft at yahoo.com for corrections/suggestions to this timeline 1882: Christian Zeller devised the Zeller's congruence algorithm for determining the day of the week for any calendar date. This algorithm is not suitable for mental calculation but works well in computer software. 1887: Lewis Carroll published a perpetual calendar algorithm in the journal Nature with the title "To Find the Day of the Week for Any Given Date". Carroll's algorithm can be performed mentally. Lewis Carroll, himself, can calculate the day of the week in about 20 seconds. 1967: Martin Gardner published "Tricks of Lightning Calculators"