Slashdot Mirror


Calendar: Code, Free Speech, Or Mathematics?

jdavidb writes: "Dr. John Conway (author of the famous "Game of Life") has a wonderful algorithm for finding the day of the week for any year in history that you can do in your head. It's so easy and elegant, in fact, that someone has decided to write a poem about it. Shades of DeCSS haikus! What a marvelous example of how mathematics is a form of (free and protected) speech. As if to further illustrate that computer code is just another form of speech, there is an implementation of this algorithm (in Perl of course)!"

49 of 147 comments (clear)

  1. Re:It's all a hoax by Russ+Steffen · · Score: 2
    What a funny game. The only way to win is not to play. There's another game like that - it's called Global Thermonuclear War...

    Sorry... Just saw "Wargames" again recently.

  2. Re:Here's the link through Google... by gmezero · · Score: 2

    Damn it! I can't even get first Google here!

  3. Re:Limitations. . . by Zagadka · · Score: 2

    The major exception is Great Britian which, due to the feud between the Catholic and Anglican Churches, did not adopt the Gregorian Calendar until September 14, 1752.

    And if you want to see something weird, but nifty, type the following into your local shell prompt:

    cal 9 1752

  4. Correction by waldoj · · Score: 5

    ...has a wonderful algorithm for finding the day of the week for any year in history that you can do in your head.

    That should read "...that one can do in one's head." I could no sooner do that in my head than I could give birth.

    -Waldo

    1. Re:Correction by Winged+Cat · · Score: 2

      I could no sooner do that in my head than I could give birth.

      I think he was speaking to most of the readers of this site. I can do it in my head easily enough.

    2. Re:Correction by b0r1s · · Score: 2

      Interestingly enough, this "new algorithm" was taught to me by Art Benjamin, who teaches some math classes (combinitorics, discrete, number theory, etc) at Harvey Mudd College ... who not only did this trick in his head for random (birthdays of students) days, but also did some very impressive multiplication (multiplying two 5 digit numbers in his head, no paper, no pencil, etc)... just some evidence that some people CAN do this in their head ...



      --
      Mooniacs for iOS and Android
    3. Re:Correction by b0r1s · · Score: 2

      I didnt say it was a trick ... but to do it quickly, and correctly, is NOT TRIVIAL... I consider myself rather intelligent, and I can not yet do it quickly, because there are simply too many digits to keep track of...

      --
      Mooniacs for iOS and Android
  5. Re:Problems w/linux hardware support by Cid+Highwind · · Score: 3

    Pure FUD.
    Linux has supported bongs with any number of chambers since kernel 2.4.1 The generic waterpipe driver has been re-written from the ground up to support bongs up to 1024 inches. The only trouble items are the so-called winpipes. These pipes don't have an actual bowl, they're just an empty tube and a driver that makes windows *act* like it's stoned. Due to poor real-world performance and their unsatisfactory smoking experience, they are unlikely to ever be supported.

    Hookah support for multiple users is now available through the tokin' ring network device. The new tokin' ring driver also supports 128-bit encryption of the smokestream, to prevent "sniffing" of the connection by local police.

    --
    0 1 - just my two bits
  6. Re:Not exactly breaking news by PD · · Score: 4

    Whining about old news has been around since Ecclesiastes, and whining in general is even older...

  7. Alternative method... by Skeezix · · Score: 2

    I'd like to point out an alternative method that I have found. I started out with a method that I read in a memory improvement book and made some modifications for the sake of simplicity and speed. What I came up with is described in the Memory Howto I've written. The method requires the memorization of 12 one-digit numbers (one for each month) which will be extraordinarily easy if you learn the other tricks in the howto such as the peg. It takes a bit of practice, but it can be very fast and IMO is simpler. Link to entire essay is in my tagline below:
    ----

    1. Re:Alternative method... by Skeezix · · Score: 2

      :) It does take some practice. The real practice is in the converting from pictures to numbers. The easy part is visualizing the crazy pictures, for most people...since the mind is very visual.
      ----

  8. Perl, in my head!?!? by sharkey · · Score: 2

    How in the heck am I going to compile Perl into my head? That's completely besides the fact that the human brain would probable go schizo trying to figure out the best way to implement the alogorithm, since there are probably too many ways to do it.

    --

    --

    --
    "Outlook not so good." That magic 8-ball knows everything! I'll ask about Exchange Server next.
  9. Re:metric calendar by kallisti · · Score: 2
    Funny you should call it the metric calendar. You see, the same people who brought us the mmetric system also tried to change the calendar, getting rid of all the "old gods" and such. This happened in France just after the Revolution and before the Reign of Terror. Guess what happened to the calendar reformers...

    Changing the calendar is not something that people accept, there were riots when the Gregorian calendar was adopted due to people being upset that they were losing 10 days. You might say people are more rational these days, but I don't see any evidence of that.

  10. And Conway does this pretty quickly! by Tchaik · · Score: 2

    He likes to ask for your birthday and by the time he's done saying "well, I can tell you that this was a" he has the weekday.
    Of course, I didn't check his answer at the time, so I presume mistakes could easily go unnoticed, but he's really good at those kinds of things. To practice he has a program in his .login that prompts for a couple of random given day of the week (and checks) and gives him his score (total time taken for 5 good answers iirc) He has the same kind of program for factoring 4 digit numbers, etc...

    (I've been privileged to be one of his student and he is truly the most amazing mind I've personally met)

  11. Re:metric calendar by Silverfish · · Score: 2

    Yeah, this is a good idea... until you actually think about it.

    According to your system the year would have only 100 days (10 days/mo * 10 mo/yr). That unfortunately is not anywhere close to reality.

    A day is defined by the time it takes the earth to rotate on its axis, and a year is defined by the time it takes our earth to orbit the sun.

    The two are interrelated in that the time for one orbit ~= time for 365 revolutions. i.e. 1 year = 365 days. There's nothing you can do about it.

    You could go to a 10 month year, with each month having 36.5 days. (or 1/2 would have 36 days and 1/2 would have 37) But is that really gaining us anything?

    To have a 100 day year as you propose, you would have to change the definition of "day" or "year", neither of which is appealing: Would yo prefer a "day" with 3.65 daylight/nighttime cycles, or having it take 3.65 "years" to complete the four seasons?

  12. Re:Google Copy by SMN · · Score: 2
    Interesting idea -- post the link to the google cache of the article when the page hasn't even gone down, with a little "sigh" to make users think otherwise. What a great way to deceive moderators and earn karma!

    (moderators: this isn't flamebait or a troll, it's just pointing out how easy it is to fool others into moderating one's post up undeservedly. You might even call it insightful =)

    --
    -- Imagine how much more advanced our technology would be if we had eight fingers per hand.
  13. Re:Is the Zeller algorithm correct ? Re:Limitation by SMN · · Score: 2
    Are you sure you're truncating, and not rounding?

    It should work as follows:
    2 + (8*26)/10 + 73 + 73/4 + 19/4 - 2*19
    = 2 + 208/10 + 73 + 18 + 4 - 38
    = 2 + 20 + 73 + 18 + 4 - 38
    = 79 % 7 = 2 -> Monday

    --
    -- Imagine how much more advanced our technology would be if we had eight fingers per hand.
  14. Re:Limitations. . . by SMN · · Score: 2
    Well, I didn't say that the Gregorian Calendar would certainly be wrong in the year 4092 -- it's just that we don't know how people will deal with the problem, so we can't be certain the date we obtain is correct and, as I said, "this algorithm should not be used for any date past December 31, 4091."

    The leap year rules might be adjusted to compensate every 4000 years, or the days might be allowed to accumulate, as you suggested. Or there might be an entirely different Calendar in use. But since we don't know, it wouldn't be a good idea to try to get one of those dates, because those are much less likely to be correct.

    --
    -- Imagine how much more advanced our technology would be if we had eight fingers per hand.
  15. Limitations. . . by SMN · · Score: 5
    There are a few very minor limitations on this algorithm that are not mentioned on the page. In fact, these limitations are ignored, and lead several mistakes on that page.

    The algorithm uses the Gregorian Calendar. Most countries did not adopt the Gregorian Calendar until October 15, 1582, and therefore it is inaccurate for any date before that. The major exception is Great Britian which, due to the feud between the Catholic and Anglican Churches, did not adopt the Gregorian Calendar until September 14, 1752.

    This means that the "Doomsday"'s before 1583 are all wrong everywhere, and those before 1753 are wrong in Great Britian.

    In addition, the Gregorian Calendar only considers Leap Year exceptions on a 400-year cycle, so in the year 4092 it will have drifted off by one full day. Therefore, this algorithm should not be used for any date past December 31, 4091.

    In my opinion, the Doomsday algorithm isn't even the best algorithm for this job. I prefer Zeller's Algorithm, for a which a good description can be found at http://www.columbia.edu/ ~cs1005/HW03.html .

    Zeller's Algorithm was first proposed by Chr. Zeller, in 1883 -- long before computers. It also allows one to find the day of week for a date using only integer division, and thus can be done easily by hand. It's much simpler than the Doomsday Algorithm appears to be.

    I can't post it here correctly due to formatting limitations, but it can be found at the above lined page. It's slightly harder to memorize, but simpler to use (and program -- only took me a few minutes).

    --
    -- Imagine how much more advanced our technology would be if we had eight fingers per hand.
    1. Re:Limitations. . . by PurpleBob · · Score: 2

      Wow. You certainly must be smarter than John Conway, then. He should take a lesson from you and, instead of teaching neat mathematical tricks, start a course in "Not Reading The Article 101".
      --

      --
      Win dain a lotica, en vai tu ri silota
    2. Re:Limitations. . . by Speare · · Score: 2

      There are a few very minor limitations on this algorithm that are not mentioned on the page. [...] The algorithm uses the Gregorian Calendar.

      The example preceding the #Origins section of the page describes the same issues about the Gregorian calender, including the fact that the Gregorian dates weren't adopted everywhere instantly.

      As for which is better for the job, I'll take Doomsday over Zeller. If I wanted a method that required integer division, I'd get out my calculator. Many sufficiently advanced calculators have a shortcut to calculate this, anyway. Perhaps Doomsday is to Bresenham as Zeller is to Interpolation.

      --
      [ .sig file not found ]
    3. Re:Limitations. . . by sv0f · · Score: 5

      I can't post it here correctly due to formatting limitations, but it can be found at the above lined page.

      I have discovered a marvelous algorithm for finding the day of the week for any date in history but the margin is too small to contain it...

    4. Re:Limitations. . . by bark76 · · Score: 5
      In addition, the Gregorian Calendar only considers Leap Year exceptions on a 400-year cycle, so in the year 4092 it will have drifted off by one full day.

      WOO HOO! That means that by 744,744AD our winters will be in the summer and vice versa, it'll be like we're living in Australia!

  16. Re:It's all a hoax by gorilla · · Score: 2

    Not terribily suprising. The chances of getting 12 correct with 12 guesses is 80!-68!, or 1 in 1,962,360,214,549,183,088,640,000. Even if a trillion guesses are played, the chances of winning are still almost 2000 trillion to 1.

  17. Now we wait... by west · · Score: 2

    Seems pretty clever. I wonder how long it will be before somebody claims a patent violation.

  18. Not exactly breaking news by gorsh · · Score: 2

    The poem has been around since 1976, and the algorhythm is even older...

    1. Re:Not exactly breaking news by tswinzig · · Score: 2

      Whining about old news has been around since Ecclesiastes, and whining in general is even older...

      Yeah, it started on a Wednesday, to be exact.

      --

      "And like that ... he's gone."
  19. Re:why the free speach worries? by linuxy · · Score: 2

    Yes, this assumes base 10. A more general, and easily provable (although I'm not going to include a proof here) rule is that in base b, b-1 divides the number iff b-1 divides the sum of the digits. If another number n divides b-1 then, n divides the sum of the digits as well. Similiary, b+1 divides the number iff if divides the alternating sum of the digits (in other words, in base 10 - 132 = 2-3+1 = 0, which is divisible by 11, so 132 is divisible by 11). Similary, numbers that divide b+1 have a similar property.

  20. Hey... by Moonshadow · · Score: 5

    This code circumvents the obfuscation put in place by the Romans way back when by allowing the masses to find the weekday equivalents of any day in history! This must be stopped! Why, if this information leaks to the masses, we'll have rebellion and revolution, and it's only a matter of time before calendar makers' proprietary secrets are laid bare, depriving them of their hard-earned money! Rest assured that we will be filing a lawsuit against the author of this code, and any who distribute it. Such criminal "crowbars" cannot be allowed to proliferate to the masses!

    Have a nice day,

    Calendar Makers Association of America.

  21. Re:why the free speach worries? by The+Good+Reverend · · Score: 2

    Regarding my above post, numbers divisible by three add up to three, six, nine, or another number divisible by three, not just three. Sorry for the quick post =)
    The Good Reverend
    I'm different, just like everybody else.

  22. Re:It's all a hoax by The+Good+Reverend · · Score: 2

    Ah...I wasn't aware. Very interesting. All the Keno games I've seen in Vegas use balls for their main game, I'm not sure about the side games, though I'm sure most do, even if it's behind the scenes. What I find facinating is that no one in Las Vegas has ever matched 12 of 12 or better (keno is a pick as many as you want from 80, and 20 are picked, for those unfamilar with the game). The odds do suck, but how many billions of keno games have been played in the last 50 years?

    The Good Reverend
    I'm different, just like everybody else.

  23. why the free speach worries? by The+Good+Reverend · · Score: 5

    What a marvelous example of how mathematics is a form of (free and protected) speech.

    Has someone tried to claim a patent on this? It's a neat little math trick, but the poster seems a little paranoid. Should we not tell the world that the digits in numbers divisible by three add up to three, in case someone tries to patent that too? It doesn't seem like this is a big problem. or even a free speech issue.

    The Good Reverend
    I'm different, just like everybody else.

    1. Re:why the free speach worries? by ryants · · Score: 2
      Has someone tried to claim a patent on this? It's a neat little math trick, but the poster seems a little paranoid.

      Well, if it catches on, calendar makers will be out of business, and we can't have that.

      Seriously I think this is a swipe at the anti-DeCSS crowd, who are trying to argue that computer code (and, by extension, mathematical algorithms) are not protected speech.

      Ryan T. Sammartino

      --

      Ryan T. Sammartino
      "Ancora imparo"

  24. Re:It's all a hoax by Delrin · · Score: 2

    Actually, I was making a "witty" commentary on something that happened here in montreal. A hyper-addicted gambler watched and recorded all the kino games for a period of time. And found a flaw in the so-called "random" number generation (computerised), he successfully was able to predict the outcome on a large number of occasions, and the Casino tried to sue him for the money back.. unsuccessfully. They then started using real balls to get the numbers. :)

  25. Here's the article I was talking about by Delrin · · Score: 2

    I found some more info here. Apparently it was 620,000$ CDN that he won. They been the odds of "1 in 6 billion" 3 times in a row. Here are some excerpts

    - Corriveau used an "antique 286" computer to analyse 7,000 combinations from the keno game, [which uses an electronic pseudo-random number generator].
    - The Casino managers shut the game down and called the police.
    - The Surete du Quebec [provincial police] fraud squad investigated; Corriveau and his family even took polygraph tests.
    Might want to look on yahoo or somewhere to find the details of the actual judgement. Though I am pretty sure he was let off completely.

  26. Bigger margins by yerricde · · Score: 2

    but the margin is too small to contain it...

    You have all the margin you want at Everything, the Internet's most popular collaboratively filtered database and writing community. (See also what I've written.)

    --
    Will I retire or break 10K?
  27. child geniuses by Theodore+Logan · · Score: 2
    Actually, being able to do this calculating is a capability often attributed to various "child prodigies". For example, Amy Wallace wrote in "The Prodigy" (a sort-of biography of William Sidis, by some (myself, for example), considered by many the greatest child prodigy ever) something like:
    • Young Sidis astounded guest with his remarkable ability to calculate the the day of any given day in a matter of seconds, using an algorithm he had invented himself.
    While Sidis undoubtly was a real prodigy, many others that are attributed with this "remarkable ability" aren't. That they are nevertheless labeled so is probably mostly due to biographers (like Wallace) overestimating the difficulty of this particular task. Not that this is really important or anything, but it always annoys me when people gravely overestimate someone's intellectual capacity merely because of simple tricks.
    --

    "If you think education is expensive, try ignorance" - Derek Bok

  28. Google Copy by Alien54 · · Score: 2
    {Sigh}

    Here is the link to the copy in the Google Cache

    enjoy!

    (oops - forgot the password)

    Check out the Vinny the Vampire comic strip

    --
    "It is a greater offense to steal men's labor, than their clothes"
    1. Re:Google Copy by Alien54 · · Score: 2
      Hate to be the one to tell you, but Vinny the Vampire is some horrendously unfunny shit. Maybe it's time for a new sig?

      No accounting for taste, of course. I'll pass the info on to the pair running it, a couple of of my teenage nephews.

      (gotta help out family and all that)

      Check out the Vinny the Vampire comic strip

      --
      "It is a greater offense to steal men's labor, than their clothes"
    2. Re:Google Copy by Alien54 · · Score: 2
      Interesting idea -- post the link to the google cache of the article when the page hasn't even gone down,

      Considering I tried to access it from work where we have the usual t-1 line, it I couldn't get it, what was I supposed to think? after all, not everyone has an OC line

      And I've been maxed for months. I wish they would tweak/fix the moderation system so that I could use some more of the karma.

      Check out the Vinny the Vampire comic strip

      --
      "It is a greater offense to steal men's labor, than their clothes"
  29. Neater code by Cassivs · · Score: 2
    Personally, I think this little snippet is much more obfuscated, and well, just more like "that's hacker code.":

    int dow(int m,int d,int y)
    {y-=m<3;return(y+y/4-y/100+y/400+"-bed=pen+mad. "[m]+d)%7;}

    Even though it only works for "a restricted range." This comes from here, which has some other information too.

    --
    -skip
  30. Re:It's all a hoax by pcidevel · · Score: 3

    Actually, I was making a "witty" commentary on something that happened here in montreal. A hyper-addicted gambler watched and recorded all the kino games for a period of time. And found a flaw in the so-called "random" number generation (computerised), he successfully was able to predict the outcome on a large number of occasions, and the Casino tried to sue him for the money back.. unsuccessfully. They then started using real balls to get the numbers. :)

    Actually that definately was not a 'flaw' persay other than the fact that the pseudo random number generator must have been displaying every number called in order.. ALL pseudo random number generators (i.e. every computer generated random number sequence) is a repetive sequence.. given the same seed it will produce the same results.. it's a fact of life, random number generation isn't possible algorithmically.. I know, I used to write them for gambling applications for a living.. What the player must have done was sit through enough iterations of the random number generator to realize what the pattern was (say, they seeded with time, using only the hours and minutes, and if the game started at 9:00 the numbers would always be the same).. I have heard rumors about this kinda stuff happening.. but I have never seen any REAL proof that a programmer was lax enough to get this out on the market.. In fact when some of my games went through the regulatory procedures, people at the agencies that verified the games had basically the same story (urban legend?) happening in atlantic city casino's.. funny enough, every time I've heard it it's been keno, but I would think there would be much easier and less detectable games to do this with (computerized blackjack)..

    It's important to realize that just like counting cards at a poker game in Vegas, this IS illegal and I'm quite sure that if it could be proven it the casino would win a lawsuit (and probably the person counting the deck so to speak would serve jail time also)...

    We got around this with our generator by selecting numbers from the deck even when we weren't being asked for a number, so a 'random' amount of numbers were drawn in between each time that a 'random' number was drawn.. that and the random seed was not only second from epoch but a serial number and various other things (like the content of a 'random' location in memory) all added together..

    Every gaming market I have been too requires at LEAST a Chi-Square test on the generator to ensure even distribution of random numbers.. Most test the random number generator much more vigorously.. I can't imagine something slipping into the field that a player could cheat easily.. It seems to me that probably this is a legend that started with someone with basic random number generator knowledge saying "Hey, theoretically you could cheat these generator's IF..." that got spread into a real legend that it happened.. but then again.. I've met some poor programmers in my time, and seen extremely lax validation agencies.. so it's possible that something like this really happened.. :)

    --

    I thought someone said there was going to be free beer!

  31. Build your own Perpetual Calendar by T1girl · · Score: 2

    I'd just as soon try to memorize the Charge of the Light Brigade as that bizarre poem. It ain't exactly "Thirty days hath September."

    But I think I could manage to make four paper strips and fold them around a pencil, or build this cardboard contraption, or even try tattooing this stuff on various body parts like the guy in Memento.

    I might try this interactive calendar to find the Doomsday to start the algorithm process, but then I wouldn't need to remember the algorithm, would I? I would be most likely to consult my desk copy of Farmer's Almanac, then the only thing I would have to remember is where I put it.

    Resisting the urge to shout "How are you, gentlemen?" every time I pass the "gentlemen's room" at work.

  32. In my head?!? by wrinkledshirt · · Score: 2
    Dr. John Conway (author of the famous "Game of Life") has a wonderful algorithm for finding the day of the week for any year in history that you can do in your head.

    Maybe, but only if one of the steps included in my head is telling myself "Remember where you put the printout to that page, dumbass."

    --

    --------
    Bleah! Heh heh heh... BLEAH BLEAH!!! Ha ha ha ha...

  33. Dr Who anual of 1978 by Zeinfeld · · Score: 2
    An algorithm that was pretty simple appeared in the Dr Who annual of 1978 (or thereabouts). It was the sort of thing one might do at the age of 12 but which rapidly becomes tedious thereafter.

    A much simpler algorithm is

    1. Open Palm VII
    2. Start Calendar
    3. Consult relevant day in calendar

    The SAS survival handbook lists hundreds of ways to stay alive in artic wastes armed with only a rusty can opener. Me I go down to the supermarket.

    Technology is good, folk should try it sometime.

    --
    Looking for an Information Security student project suggestion?
    Try http://dotcrimeManifesto.com/
  34. Re:It's all a hoax by ryants · · Score: 2
    If you're looking to win at gambling, ... play blackjack - that's as close as you're going to get to having "good" odds.

    Horse racing is better, since you aren't competing against the house (they just take a fixed cut), but rather you're competing against the other gamblers.

    My best summer job was working at the local race track and watching my high school principal gamble away his daughter's inheritance week in, week out.

    Ryan T. Sammartino

    --

    Ryan T. Sammartino
    "Ancora imparo"

  35. Editors are Retarded by Razzious · · Score: 2

    I think back to a movie about a Savant(Rainman)...Seems that they want us all to be autistic and wonder aimlessly figuring calculations in our head...Meantime i get my palm out of my pocket protector, pull my half keyboard and go about it the old fashioned way....


    I am accepting donations for more bow-ties and a new pair of coke bottle glasses.


    Razzious Domini

    --
    Razzious Domini
    I could be a GREAT KARMA WHORE if I could just shed the few morals I have left.
  36. Easy to remember? by Purple_Walrus · · Score: 4

    "Easy to remember" means remembering your own name. "Easy to remember" means basic rules of addition. This is more like "painstakingly difficult to remember under any circumstances."
    I'll stick to using my calendar, thank you very much!
    ---

    --
    ------
    Sig
  37. An open source application uses this algorithm by ayers · · Score: 4
    CalendarBuilder.asp, a combination VBScript/JavaScript Server Page implements this algorithm.

    Source code available at webware.skybuilders.com

    The calendar built by this page is part of skyBuilders timeLines

    dtd

    Any sufficiently advanced technology is indistinguishable from magic.
    - Arthur C. Clarke