Perl script reveals math trick

MIND GAMES

Author(s):

A trick that anybody can learn lets you determine the day of the week from the date. We’ll apply some Perl technology to discover whether the method is reliable.

Recently, I was reading Mind Performance Hacks and stumbled across Hack Number 43, which explains how to determine the day of the week for any given date. The method is attributed to Lewis Carroll], the author of Alice’s Adventures in Wonderland. Simply calculate four values, one after the other, for the year, month, and day, and a fourth value as an adjustment factor. Then add the values, divide by 7, and the remainder amazingly gives you the day of the week as a number between zero (Sunday) and six (Saturday).

Read full article as PDF:

078-080_perl.pdf  (399.36 kB)

Related content

  • Perl: DateTime Module

    Because calendar rules are influenced by historical and political decisions, date manipulations are riddled with pitfalls. Perl’s DateTime module knows all the tricks.

  • Command Line: cal and date

    The legacy cal and date tools help users keep track of the time and date. You can even change the system time with a single shell command.

  • Letters
  • Perl: Portfolio Watch

    We'll show you a Perl script that helps you draw area graphs to keep track of your portfolio's performance.

  • Command Line: Cal, Date, Hwclock, NTP

    I’m late, I’m late, for a very important date. For many applications, it is important that your PC has the correct time and time zone. We’ll show you how to keep your PC clock ticking and how to use NTP to synchronize the time with a time server on the Web.

comments powered by Disqus

Direct Download

Read full article as PDF:

078-080_perl.pdf  (399.36 kB)

News