Post Reply 
2024 HHC Programming Contest - RPN #2
09-21-2024, 03:26 PM (This post was last modified: 09-21-2024 03:26 PM by Gene.)
Post: #1
2024 HHC Programming Contest - RPN #2
Here is the RPN programming contest #2 from this year's HHC.

PLEASE do not post any solutions until 6am CENTRAL USA time MONDAY 9/23/2024.

Thank you.


Attached File(s)
.pdf  HHC 2024 RPN Programming Contest - 2 - v1.1.pdf (Size: 62.46 KB / Downloads: 126)
Find all posts by this user
Quote this message in a reply
09-21-2024, 07:32 PM (This post was last modified: 09-21-2024 07:34 PM by Gene.)
Post: #2
RE: 2024 HHC Programming Contest - RPN #2
Couple of typos at the top of page 2 of the PDF. Really don't affect much, but in the interest of making sure... :-)

-------------------------------------
So the assignment is to write a LBL FLOAT ... END program.

Examples:
2 ENTER 4 / XEQ FLOAT should return a display of 0.5
3 ENTER 4 / XEQ FLOAT should return a display of 0.75
3.005 ENTER 4 / XEQ FLOAT should return a display of 0.75125
1 CHS ENTER 9 / XEQ FLOAT should return a display of -0.111111111
1.25 ENTER 3.75 + XEQ FLOAT should return a display of 5.
0 ENTER 0 + XEQ FLOAT should return a display of 0.
1 ENTER 4 / XEQ FLOAT 3.125 + XEQ FLOAT 8 / XEQ FLOAT should return a display of
0.421875.

The goal here is to make very little or no splash with your FLOAT routine.

-------------------------------------
Find all posts by this user
Quote this message in a reply
09-23-2024, 02:20 PM (This post was last modified: 09-23-2024 02:32 PM by Werner.)
Post: #3
RE: 2024 HHC Programming Contest - RPN #2
( edited a few times as I forgot to check The Rules)

Code:
01 LBL”FLOAT”
02 -8
03 X<>Y
04 ENTER
05 LBL 10
06 FIX IND Z
07 RND
08 X#Y?
09 GTO 00
10 ISG Z
11 GTO 10
12 LBL 00
13 DSE Z
14 LBL 00
15 RDN
16 X<>Y
17 RDN
16 FIX IND T
17 END

36 bytes, and I lose Z, T and L, so the score would be 36+21=57
Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
09-24-2024, 06:55 AM
Post: #4
RE: 2024 HHC Programming Contest - RPN #2
Mh this program does not return the correct result for small numbers such as 6.885 E-08, so here’s a correction:

Code:
 01 LBL "FLOAT"
 02 -8
 03 X<>Y
 04 ENTER
 05 FIX 9
 06 RND
 07 X=Y?
 08 GTO 10
 09 RDN
 10 ENTER
 11 LBL 09
 12 SCI IND Z
 13 RND
 14 X≠Y?
 15 GTO 00
 16 ISG Z
 17 GTO 09
 18 LBL 00
 19 DSE Z
 20 LBL 00
 21 RDN
 22 X<>Y
 23 RDN
 24 SCI IND T
 25 RTN
 26 LBL 10
 27 FIX IND Z
 28 RND
 29 X≠Y?
 30 GTO 00
 31 ISG Z
 32 GTO 10
 33 LBL 00
 34 DSE Z
 35 LBL 00
 36 RDN
 37 X<>Y
 38 RDN
 39 FIX IND T
 40 END

The score is now 65 + 21 = 86

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
09-24-2024, 10:03 AM
Post: #5
RE: 2024 HHC Programming Contest - RPN #2
Surely a bonus prize of some type is due for using probably the most obscure command I've seen in a program listing in years:

FIX INT T or SCI IND T or SCI IND Z, etc.

Well done Werner!

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
09-24-2024, 12:08 PM (This post was last modified: 09-24-2024 12:10 PM by Craig Bladow.)
Post: #6
RE: 2024 HHC Programming Contest - RPN #2
My solution from the conference that came in at 82 bytes plus 7 bytes for not preserving T.
X, Y, Z and L are preserved which makes it quite usable. This was not the winner. As the loop is unrolled it may be a contender for the most responsive on any 41 platform.
Code:

LBL "FLOAT"
FIX 00
XEQ 00
FIX 01
XEQ 00
FIX 02
XEQ 00
FIX 03
XEQ 00
FIX 04
XEQ 00
FIX 05
XEQ 00
FIX 06
XEQ 00
FIX 07
XEQ 00
FIX 08
XEQ 00
FIX 09
LBL 00
CLA
ARCL X
69
POSA
X>0?
GTO 02
RDN
ANUM
X=Y?
GTO 01
LBL 02
RDN
RTN
LBL 01
RDN
STOP
END

Try CC41!
Find all posts by this user
Quote this message in a reply
09-24-2024, 05:36 PM
Post: #7
RE: 2024 HHC Programming Contest - RPN #2
Ah, the use of the alpha register does not get penalized? Didn’t check the Rules thoroughly enough ;-)
BTW the routine I posted is a quick hack and can be improved ;-) I’m rather far away from my desk (LA, heading back home) and wrote it on the fly, literally.
W.

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
09-24-2024, 05:39 PM
Post: #8
RE: 2024 HHC Programming Contest - RPN #2
Here is my entry during the conference, it comes in at 43 bytes plus 14 bytes penalty for not preserving T and L

Juan

Code:

 01 LBL "FLOAT"
 02 CLA
 03 9
 04 LBL 01
 05 XTOA
 06 DSE X
 07 LBL 03
 08 10^X
 09 X<>Y
 10 *
 11 LASTX
 12 X<>Y
 13 FRC
 14 X#0?
 15 GTO 02
 16 RDN
 17 ATOX
 18 DSE X
 19 GTO 01
 20 LBL 02
 21 RDN
 22 ATOX
 23 RDN
 24 FIX IND T
 25 END
Find all posts by this user
Quote this message in a reply
09-24-2024, 06:15 PM (This post was last modified: 09-24-2024 06:35 PM by AnnoyedOne.)
Post: #9
RE: 2024 HHC Programming Contest - RPN #2
(09-24-2024 10:03 AM)rprosperi Wrote:  Surely a bonus prize of some type is due for using probably the most obscure command I've seen in a program listing in years:

Almost as obscure as using f FIX I, f SCI I or f ENG I on a HP-15C Smile

Code:

   001 {    42 21 11 } f LBL A
   002 {           9 } 9
   003 {       44 25 } STO I
   004 {    42 21  0 } f LBL 0
   005 {    42  7 25 } f FIX I
   006 {       45 25 } RCL I
   007 {       42 31 } f PSE
   008 {    42  5 25 } f DSE I
   009 {       22  0 } GTO 0
   010 {    43 30  1 } g TEST x>0
   011 {       22  0 } GTO 0
   012 {       43 32 } g RTN

A1

HP-15C (2234A02xxx), HP-16C (2403A02xxx), HP-15C CE (9CJ323-03xxx), HP-20S (2844A16xxx), HP-12C+ (9CJ251)

Find all posts by this user
Quote this message in a reply
09-24-2024, 06:47 PM
Post: #10
RE: 2024 HHC Programming Contest - RPN #2
(09-24-2024 05:36 PM)Werner Wrote:  Ah, the use of the alpha register does not get penalized? Didn’t check the Rules thoroughly enough ;-)

I had the same concern and asked Gene, he said something to the effect of "whatever the rules say", which I took to mean alpha is not mentioned in the rules, hence not penalized. In case his answer had been different, I had in my back pocket a 41 bytes alternative that preserved alpha, but lost Z, T and L

Code:

 01 LBL "FLOA2"
 02 9
 03 LBL 01
 04 STO T
 05 DSE X
 06 LBL 03
 07 10^X
 08 X<>Y
 09 *
 10 LASTX
 11 X<>Y
 12 FRC
 13 X#0?
 14 GTO 02
 15 RDN
 16 RCL Z
 17 DSE X
 18 GTO 01
 19 STO T
 20 LBL 02
 21 RDN
 22 FIX IND Z
 23 END
Find all posts by this user
Quote this message in a reply
09-27-2024, 06:58 AM
Post: #11
RE: 2024 HHC Programming Contest - RPN #2
(09-24-2024 05:39 PM)born2laser Wrote:  Here is my entry during the conference, it comes in at 43 bytes plus 14 bytes penalty for not preserving T and L

Juan

6.885E-7 -> 0.000000689 io. 6.885E-07
6.885E12 -> 7E12 io 6.885E12
PI 1000 / -> 0.003141593 io. 3.1415926E-03

It's surprisingly difficult to get right ;-) My own two posted programs don't, either.
Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
09-27-2024, 07:09 AM
Post: #12
RE: 2024 HHC Programming Contest - RPN #2
(09-21-2024 07:32 PM)Gene Wrote:  Couple of typos at the top of page 2 of the PDF. Really don't affect much, but in the interest of making sure... :-)

-------------------------------------
So the assignment is to write a LBL FLOAT ... END program.

Examples:
2 ENTER 4 / XEQ FLOAT should return a display of 0.5
3 ENTER 4 / XEQ FLOAT should return a display of 0.75
3.005 ENTER 4 / XEQ FLOAT should return a display of 0.75125
1 CHS ENTER 9 / XEQ FLOAT should return a display of -0.111111111
1.25 ENTER 3.75 + XEQ FLOAT should return a display of 5.
0 ENTER 0 + XEQ FLOAT should return a display of 0.
1 ENTER 4 / XEQ FLOAT 3.125 + XEQ FLOAT 8 / XEQ FLOAT should return a display of
0.421875.

The goal here is to make very little or no splash with your FLOAT routine.

-------------------------------------

While STD setting on an RPL machine does produce -.11111.. 11, it doesn't display a leading zero, and can thus show all digits. The same does not hold for the 41. ALL setting on the 42S shows -1.11..11E-01 in this case, but then, the 42S can show all digits AND the exponent, which, again, the 41 cannot. So, what should FLOAT do?

- show the maximum number of digits?
PI: 3.141592654
PI/10: 0.314159265
PI/100: 0.031415927
PI/1000: 3.1415926E-03 (SCI 08 or SCI 09) or 3.1415927E-03 (SCI 07)
(this is a nightmare to implement)

- only show all digits when possible
PI: 3.141592654
PI/10: 3.1415926E-1 or 3.1415927E-1
(.. which goes against the Rules)

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
09-27-2024, 11:58 AM
Post: #13
RE: 2024 HHC Programming Contest - RPN #2
At the conference we said to show the maximum number of digits and not to worry about scientific notation etc.

The usual leading zero on the HP-41 was assumed to always show.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 4 Guest(s)