Thursday, October 10, 2019

HP 41C/DM 41: Halloween and Thanksgiving - Calendar Calculations

HP 41C/DM 41:  Halloween and Thanksgiving - Calendar Calculations

Introduction 



We are about to enter the annual holiday season, and it's can be hard to remember when all the holidays.  Here is a way to determine what date Thanksgiving will be on this year, and all you have to know is what day of the week Halloween falls on.

Halloween is celebrated on October 31.  Halloween is celebrated on a fixed date, while Thanksgiving is celebrated on a fixed day of the week.

In the United States, Thanksgiving is on the fourth Thursday in November.  Therefore the only dates Thanksgiving in the United States is between November 22 and November 28.

In Canada, Thanksgiving is on the second Monday in October, which lands the possible dates between October 8 and October 14. 

Determine The Date of Thanksgiving Knowing What Day of the Week Halloween Is On

The first step is to give each day a numeric value:

Sunday: 0
Monday:  1
Tuesday:  2
Wednesday:  3
Thursday:  4
Friday:  5
Saturday:  6

To determine what date Thanksgiving falls on in the United States:

1.  Let H be the numeric value for the day Halloween falls on (see the above chart). 
2.  Subtract 4 from H.
3.  If the result is zero or negative, add 28; otherwise, add 21. 

Note:  The following programs could address alternative approaches given what the command set of the HP 41C/DM 41 allows us to do. 

HP 41C/DM 41 Program:  H>T

01 LBL^T  H>T
02 4
03 X<>Y
04 -
05 X>0?
06 GTO 01
07 7
08 +
09 LBL 01
10 21
11 + 
12 RTN

To determine what date Thanksgiving falls on in Canada:

1.  Let H be the numeric value for the day Halloween falls on (see the above chart). 
2.  Subtract H from 7. 
3.  Subtract 3 from the last result.
4.  If the result from Step 3 is zero or negative, add 14; otherwise, add 7.

HP 41C/DM 41 Program: H>CT

01 LBL^T H>CT
02 7
03 X<>Y
04 -
05 3
06 -
07 X>0?
08 GTO 01
09 7
10 +
11 LBL 01
12 7
13 + 
14 RTN

Now, let's go the other way.

Determine The Day of the Week Halloween Knowing the Date of Thanksgiving

The first step is to give each day a numeric value:

Sunday: 0
Monday:  1
Tuesday:  2
Wednesday:  3
Thursday:  4
Friday:  5
Saturday:  6

To determine the day of the week Halloween falls on given the date of Thanksgiving (United States):

1.  Let T be the date of Thanksgiving.
2.  Subtract 21 from T. 
3.  Subtract the result from Step 2 from 4.  If the number is negative, add 7.  See the above chart to determine the Day of the Week.

HP 41C/DM41 Program:  T>H

01  LBL^T T>H
02 21
03 - 
04 4
05 X<>Y
06 -
07 X<0 font="">
08 GTO 01
09 RTN
10 LBL 01
11 7
12 + 
13 RTN

To determine the day of the week Halloween falls on given the date of Thanksgiving (Canada):

1.  Let T be the date of Thanksgiving.
2.  Subtract T from 11.  If the result is negative, add 7.  See the above chart to determine the Day of the Week.

HP 41C/DM41 Program:  CT>H

01 LBL^T CT>H
02 11
03 X<>Y
04 -
05 X<0 font="">
06 GTO 01
07 RTN
08 LBL 01
09 7
10 +
11 RTN

Are you ready for the holiday season?  I'm not sure I am.  Let's have fun,

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.