HP Forums
Back on Forum - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: Back on Forum (/thread-5823.html)



Back on Forum - ggauny@live.fr - 03-06-2016 12:43 PM

Hello for all of you,

I am happy to be back with you all. I was in deasease.
I submit, as present, you a little routine that it is from Joe Horn and a friend of He which optmized. It is "friday the 13" in any year in gregorian.

[/code]
LBL'FRI'
LBL'A' // Because it is more queeker
6
10^x // it is ALOG
/
13.12
+
#011
STO 00
DROP
ENTER
ENTER
4.043
DELTADAYS
7
MOD
x=0?
SF00
DROP
FS?C00
ENTER
ENTER
0.01
-
DSE 00
BACK 022
DROP
END[/code]
[code]

This give all fridays the 13 in a year.
I thank people they have asked me.

I don't forget JEBEM


RE: Back on Forum - Didier Lachieze - 03-06-2016 02:31 PM

Welcome back Gérard !
We were a bit worried about your absence. I hope your OK now, and that you have recovered from your sickness.


RE: Back on Forum - d b - 03-06-2016 03:27 PM

Yes. Welcome back Gérard.


RE: Back on Forum - Sylvain Cote - 03-06-2016 03:46 PM

Bonjour Gérard,
Heureux de vous revoir sur le site.
J'espère que vous êtes complètement rétablis.
Sylvain


RE: Back on Forum - Dieter - 03-06-2016 07:10 PM

(03-06-2016 12:43 PM)ggauny@live.fr Wrote:  I am happy to be back with you all. I was in deasease.

Ah, welcome back then. :-)

(03-06-2016 12:43 PM)ggauny@live.fr Wrote:  I submit, as present, you a little routine that it is from Joe Horn and a friend of He which optmized. It is "friday the 13" in any year in gregorian.

Thank you very much.

Here is a version that works in any date mode (d.my, m.dy or y.md). It returns all dates where the 13th is a Friday, starting at the year entered in X. One data register is required – here I chose the I-register.

Code:
LBL A
FILL       ' fill stack with year
CLx        ' set month = 0
LBL 01
INC X      ' increment month
STO I      ' save month in I
#013
x>? Y      ' month < 13 ?
SKIP 004   ' then continue
STO/ Y     ' else set month = 1
STO/ I     ' also do so with saved month
INC Z      ' increment year in Z
INC T      ' and in T
→DATE      ' generate date according to mode setting
ENTER
WDAY       ' determine day of week
#005
-
x≠0?       ' is it not a Friday?
SKIP 005   ' then continue
CLα        ' else prepare output
DROP
αDATE      ' format date in Alpha
#005
PROMPT     ' show date & "5" for Friday
cDROP      ' DROP two levels
RCL I      ' recall month
GTO 01     ' and continue with next one

Example:

Code:
2010 [A]    =>  13.08.2010
     [R/S]  =>  13.05.2011
     [R/S]  =>  13.01.2012
     [R/S]  =>  13.04.2012
     [R/S]  =>  13.07.2012
     [R/S]  =>  13.09.2013
     [R/S]  =>  13.12.2013
     [R/S]  =>  13.06.2014
     [R/S]  =>  13.02.2015
      ...

But somehow I do not like this trial-and-error approach. I would prefer a more analytic algorithm: determine the day of week for 13 January, calculate the next Friday 13th from this, finally add a certain number of days for the next one.

But this would get much more complicated than the current method. ;-)

Dieter


RE: Back on Forum - Dwight Sturrock - 03-06-2016 07:18 PM

Great to have you back! Glad to hear you are feeling better.


RE: Back on Forum - Jlouis - 03-06-2016 07:40 PM

Good news, you're better and back!

Cheers!


RE: Back on Forum - rprosperi - 03-06-2016 09:33 PM

(03-06-2016 12:43 PM)ggauny@live.fr Wrote:  Hello for all of you,

I am happy to be back with you all. I was in deasease.

Welcome back Gérard, glad you are feeling better; good to see you come back with a contribution. Your enthusiasm and smile were missed.


RE: Back on Forum - Etienne Victoria - 03-06-2016 09:37 PM

Bonjour Gérard,

Heureux de vous revoir parmi nous !

A bientôt !

Amicalement

Etienne


RE: Back on Forum - ggauny@live.fr - 03-07-2016 09:20 AM

Hi,
Many thanks for good wishes from you all !
It is a great pleasure for me for your concern of me.
Thanks.


RE: Back on Forum - ggauny@live.fr - 03-07-2016 12:02 PM

Dear Dieter,
I well recognize you because always a better solution of routine ! Because you said in the past that it is better use not LBL and GTO, but BACK, I have tryed Back 023 in replacing GTO 01, and of course I Ruber the LBL01. It run.

I know it is possible to do the algorithm you say but I don't know how.

Good day.


RE: Back on Forum - Thomas Radtke - 03-07-2016 12:05 PM

Welcome back, hope you've completely recovered!


RE: Back on Forum - Dieter - 03-07-2016 12:57 PM

(03-07-2016 12:02 PM)ggauny@live.fr Wrote:  Because you said in the past that it is better use not LBL and GTO, but BACK,

Well, it's not better, but faster and it saves a label. But in this case I simply was too lazy to count or calculate the number of steps for the BACK command. ;-)

(03-07-2016 12:02 PM)ggauny@live.fr Wrote:  I have tryed Back 023 in replacing GTO 01, and of course I Ruber the LBL01. It run.

Yes, of course it should.

(03-07-2016 12:02 PM)ggauny@live.fr Wrote:  I know it is possible to do the algorithm you say but I don't know how.

So do I (at the moment ;-)). The Prime program in your attachment uses a similar method in that it calculates the next Friday 13th from the weekday of Jan 13. As far as I know newer versions of the Prime contain date-related commands (correct me if I'm wrong here), so it should be possible to get a more compact program.

Dieter


RE: Back on Forum - Dieter - 03-09-2016 09:14 PM

(03-06-2016 12:43 PM)ggauny@live.fr Wrote:  I submit, as present, you a little routine that it is from Joe Horn and a friend of He which optmized. It is "friday the 13" in any year in gregorian.

I think I now understand how your program is supposed to work. It returns all Friday 13 dates on the stack so that they can be viewed with R↓ or SHOW.

However, since up to three dates per year can occur and at least two stack levels are required for the calculation, setting SSIZE8 is mandatory. Also the program has to run through all 12 months and not just 11.

Here is a version that should come close to what you had in mind:

Code:
LBL A
STO 00
D.MY
SSIZE8
CLSTK
RCL 00
#012
STO 00
#013
→DATE
LBL 01
RCL X
WDAY
#005
-
x≠0?
SKIP 003
DROP
ENTER
ENTER
DROP
#001
SDR 002
-
DSZ 00
GTO 01
DROP
END

Example:
2012 [A] returns all three Friday 13 dates on the stack:

13.072012
13.042012
13.012012

If you prefer the m.dy date format, simply set line 3 accordingly and omit the SDR 002 command near the end of the program.

Dieter


RE: Back on Forum - Dieter - 03-12-2016 12:30 PM

(03-09-2016 09:14 PM)Dieter Wrote:  Here is a version that should come close to what you had in mind:

And finally here are two versions that will work both with 4 and 8 stack levels. Here the fifth level was saved by checking if the 9th of a month is a Monday.

This version uses the d.my date format:

Code:
LBL A
D.MY
FP?
YEAR
STO L
CLSTK
RCL L
#012
STO 00
#013
→DATE
LBL 01
#004
+/-
RCL+ Y
WDAY
x≠1?
SKIP 003
DROP
ENTER
SKIP 001
DROP
STO L
DROP
,
0
1
+/-
RCL+ L
DSZ 00
GTO 01
DROP
END

And here is a version for users in the m.dy region. It does not even require a data register.

Code:
LBL B
M.DY
FP?
YEAR
STO L
CLSTK
RCL L
#012
#013
→DATE
LBL 01
#004
+/-
RCL+ Y
WDAY
x≠1?
SKIP 003
DROP
ENTER
SKIP 001
DROP
DEC X
FP
X<> L
x≠? L
GTO 01
DROP
END

Example:
2012 [A] returns all three Friday 13 dates on the stack:

13.072012
13.042012
13.012012

2012 [B] does the same in m.dy format:

7.132012
4.132012
1.132012

Instead of a year also a date within that year can be entered, e.g. it doesn't matter if you enter 2012 or 04.052012.

Dieter