HHC 2017 RPN Programming contest information and results thread

09192017, 09:11 PM
Post: #41




RE: HHC 2017 RPN Programming contest information and results thread
It was 10 for RPN and 5 for RPL.
I did not highlight all entries, just the top 2 or 3 in each. 

09202017, 03:10 PM
Post: #42




RE: HHC 2017 RPN Programming contest information and results thread
After 40 years of not programming on my HP41CX, I was just "HAPPY" to come up with a program that worked correctly even though my solution was 82b, (didn't count the registers). I spent most of my time trying to figure out how to format the display to show characters and the loop count, as well as merging "un" with "happy". Was in the process of optimizing to eliminate registers when time ran out. Congratulations to Roger Hill for winning the RPN programming contest. And congrats to Werner who came up with a nice 66b solution. Now that I can see all of the tips and tricks, I'll be armed with all of the shortcuts and clever stack manipulation for HHC 2018's contest!
Also, thank you to Gene for coming up with a challenging contest. (BTW....the program ran MUCH faster on my phone emulator for the HP41CX) 

09202017, 03:16 PM
Post: #43




RE: HHC 2017 RPN Programming contest information and results thread
I'm curious. Is there a table that shows the number of bytes that each instruction takes on the HP41CX? I'd love to have that for future reference.


09202017, 03:32 PM
Post: #44




RE: HHC 2017 RPN Programming contest information and results thread
(09202017 03:16 PM)jjohnson873 Wrote: I'm curious. Is there a table that shows the number of bytes that each instruction takes on the HP41CX? I'd love to have that for future reference. Here's one: http://www.hpmuseum.org/prog/bytetab.htm That page also has a link to a more detailed table. The table only covers the basic HP41C instruction set; all the additional functions in the CX are two bytes. 

09202017, 03:35 PM
(This post was last modified: 09202017 03:40 PM by Didier Lachieze.)
Post: #45




RE: HHC 2017 RPN Programming contest information and results thread
The byte count is included in the Function Tables at the end of the HP 41CX Owner's Manual Vol. 2


09232017, 04:31 PM
Post: #46




RE: HHC 2017 RPN Programming contest information and results thread
Winning RPN Program entry HHC 2017 by Roger Hill.
70 bytes LBL "HAPPY" "UN" ABS CLST LASTX X<>Y LBL 01 RDN ISG Z LBL 02 10 / ENTER FRC X^2 STO+ Z RDN INT X != 0? (X NOT EQUAL TO ZERO) GTO 02 X<>Y 2 10^X * 4 X=Y? GTO 03 SIGN X !=Y? (X NOT EQUAL TO Y) GTO 01 CLA LBL 03  "HAPPY " (APPEND HAPPY AND A SINGLE SPACE) FIX 0 CF 29 ARCL T FIX 4 SF 29 AVIEW END 

09242017, 11:37 PM
Post: #47




RE: HHC 2017 RPN Programming contest information and results thread
Congratulations Roger! And his solution doesn't need any of the extra instructions one gets with an HP41cx.
Thanks Gene for a great contest this year! Check out NQ41! 

10012017, 09:50 PM
(This post was last modified: 10062017 06:32 PM by Jeff O..)
Post: #48




RE: HHC 2017 RPN Programming contest information and results thread
Best I could do on my own before checking the solutions here was 70 bytes, no registers. I kept searching the manual for a command to convert a byte code to a number (to avoid 48, ), but sadly, no such command exists. Using SIGN in lieu of RDN, 1 drops mine to 69 bytes. (I'll never remember that function!) Without a major rewrite that would likely just turn it into one of the ones provided by others, I don't see any opportunities for improvement. The improved (using SIGN) program is provided below for review.
Thanks Gene, another fun and interesting challenge. Maybe I am mistaken, but it seems like there are lots more "Unhappy" than "Happy" numbers. Is this true? Did anyone figure out what the highest number of cycles for a 10 digit or smaller number leading to a "Happy" result is? Code: 01 LBL HAPPY Dave  My mind is going  I can feel it. 

10012017, 11:14 PM
(This post was last modified: 10012017 11:16 PM by Don Shepherd.)
Post: #49




RE: HHC 2017 RPN Programming contest information and results thread
(10012017 09:50 PM)Jeff O. Wrote: Did anyone figure out what the highest number of cycles for a 10 digit or smaller number leading to a "Happy" result is? I think Eric Smith figured it out (for an unhappy number): 16 cycles for number 15,999. I don't know if anyone figured out the largest number of cycles leading to a happy number. 

10022017, 07:30 PM
(This post was last modified: 10062017 06:31 PM by Jeff O..)
Post: #50




RE: HHC 2017 RPN Programming contest information and results thread
Answering my own questions:
(10012017 09:50 PM)Jeff O. Wrote: ... Maybe I am mistaken, but it seems like there are lots more "Unhappy" than "Happy" numbers. Is this true?Well, for the numbers 1 through 1000 (calculated using excel, not my program above), 143 are "Happy" and 857 are "Unhappy". So this implies more "Unhappy" results. But my guess is that there are infinite "Happy" and infinite "Unhappy" numbers, and I'm not sure this is a case where one infinity is bigger than another. (10012017 09:50 PM)Jeff O. Wrote: Did anyone figure out what the highest number of cycles for a 10 digit or smaller number leading to a "Happy" result is?I will go out on a limb and postulate that the maximum number of cycles for a 10 or fewer digit number leading to a "Happy" result is 7. I will further postulate that the largest "Happy" number of 10 digits or less requiring 7 cycles is 9,999,999,998, and the smallest such number is 78,999. Dave  My mind is going  I can feel it. 

« Next Oldest  Next Newest »

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