HP Forums

Full Version: (49G) Friday 13th calculation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The programme returns the dates of Friday 13th for a valid year entry using dd.mmyyyy format.

The programme works for versions 1.19-6 & 2.10-8.

Eg For 1,953 the programme returns 13.021953, 13.031953 & 13.111953.

::
CK1&Dispatch
BINT1
::
% 1000000.
%/
%13
%+
BINT12
ZERO_DO
% .01
%+
DUP
% 13.063
DDAYS
%7
%MOD
%0=
IT
DUP
LOOP
DROP
;
;

Improvements welcome.
Here's my ancient User RPL version, which was included in "One-Minute Marvels" by Richard Nelson and Wlodek Mier-Jedrzejowicz:

Code:
<<  1000000  /  1.13  +  13  FOR  d  6.133  d  DDAYS  7  MOD  NOT  d  IFT  NEXT  >>

Since there are not many ways of doing it, the code looks very much like yours.

Same input as yours: Just the desired year. However, my version assumes MDY mode. Changing it to DMY is left as an exercise for the student.
Is this from Conway? Is there a pointer to a formula or discussion on this?
(06-22-2014 06:16 AM)Joe Horn Wrote: [ -> ]Here's my ancient User RPL version, which was included in "One-Minute Marvels" by Richard Nelson and Wlodek Mier-Jedrzejowicz:

Code:
<<  1000000  /  1.13  +  13  FOR  d  6.133  d  DDAYS  7  MOD  NOT  d  IFT  NEXT  >>

Since there are not many ways of doing it, the code looks very much like yours.

Same input as yours: Just the desired year. However, my version assumes MDY mode. Changing it to DMY is left as an exercise for the student.

I probably copied Joe Horn's prog some time ago. Credit to him.
Such a program should of course be independent of the date format setting.
Try this:
Code:
\<<
  6 ALOG / 12.12 + 
  1 12 START
    1 DATE+
    DUP 4.043 DDAYS 7 MOD NOT DUPN
    1.01 -
  NEXT
  DROP
\>>

Cheers, Werner
(06-22-2014 06:16 AM)Joe Horn Wrote: [ -> ]"One-Minute Marvels"
...Changing it to DMY is left as an exercise for the student.

"One-Minute Marvels" = pretty cool.
...I like PUSH POPs Smile
(06-23-2014 10:21 PM)CosmicTruth Wrote: [ -> ]"One-Minute Marvels" = pretty cool.

Indeed! These are the very reason I, and a whole bunch of other folks, decided learning RPL was worth the time and effort. These and the EduCalc Technical Notes (also avail at hpcalc.org) are your best tools if trying to convince a friend (or yourself) to learn RPL. Real Good Stuff!!
(06-23-2014 08:11 AM)Werner Wrote: [ -> ]Such a program should of course be independent from the date format setting.
Try this:
Code:
\<<
  6 ALOG / 12.12 + 
  1 12 START
    1 DATE+
    DUP 4.043 DDAYS 7 MOD NOT DUPN
    1.01 -
  NEXT
  DROP
\>>

Cheers, Werner

Now THAT is a thing of beauty. Smile
Thanks, Joe.
I missed the obvious shortcut: take -5. 6. START NEXT i.o. 1 12 START NEXT
Now it's 86.5 bytes - shorter than your original ;-)

Code:
\<<
  6. ALOG / 12.12 + 
  -5. 6. START
    1. DATE+
    DUP 4.043 DDAYS 7. MOD NOT DUPN
    1.01 -
  NEXT
  DROP
\>>

Cheers, Werner
Those are pretty. Some time ago I read somewhere, I forget where, that over the years, the most frequent day for a 13th was a Friday, or the other way around. It should be easy to verify with these programs. Good for a coffee break.
(06-24-2014 07:30 AM)Werner Wrote: [ -> ]Now it's 86.5 bytes - shorter than your original ;-)

[Image: notworthy.gif]
(06-24-2014 02:05 PM)Alberto Candel Wrote: [ -> ]Those are pretty. Some time ago I read somewhere, I forget where, that over the years, the most frequent day for a 13th was a Friday, or the other way around. It should be easy to verify with these programs. Good for a coffe break.

Unless my User RPL has bugs, you're right. The calendar repeats exactly every four centuries, so all we need to do is tally all 4800 13ths from 2000 through 2399. Here's what I got:

684 Thursdays & Saturdays
685 Mondays & Tuesdays
687 Sundays & Wednesdays
688 Fridays!
Reference URL's