Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Presuming you cared about the date when you wore it and didn't just let it drift, the answer is April or March, 2001.

    Since the watch goes through a 31-day cycle, it loses 7 days on a non-leap year (two in February, and one each in April, June, September, and November). Since this is March 2003, it's lost 2 days this year, 7 days in 2002, and 4 days in 2001, which puts it at April or March.

    This was fun. If you listen to NPR, you may want to submit it as the Car Talk puzzler [cars.com]!

    • Very close. :-)

      It does lose 7 days in a non-leap year but that includes 3 days in February and not 2. So it lost 3 days this year. Thus, the date would have been correct in May and June 2001.

      I also asked this question on PerlMonks [perlmonks.org] and Bart Lateur [perlmonks.org] came up with the following, rather nice, solution:

      #!/usr/bin/perl -wl

      my $time = time;
      while($time > 0) {
          print scalar localtime($time) if (localtime($time))[3] == 7;
      } continue {
          $time -= 31*24*60*60;
      }

      __END__
      Prints:

      Thu Jun  7 13:50:50 2001
      Mon May  7 13:50:50 2001
      Fri Feb  7 12:50:50 1997
      Tue Jan  7 12:50:50 1997
      Sat Dec  7 12:50:50 1996
      Tue Apr  7 13:50:50 1992
      Sat Mar  7 12:50:50 1992
      Mon Sep  7 13:50:50 1987
      Fri Aug  7 13:50:50 1987
      Tue Jul  7 13:50:50 1987
      Wed Jun  7 13:50:50 1978
      Sun May  7 13:50:50 1978
      Thu Feb  7 12:50:50 1974
      Mon Jan  7 12:50:50 1974
      Fri Dec  7 12:50:50 1973