Post Reply 
HHC 2017 RPN Programming contest information and results thread
09-19-2017, 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.
Find all posts by this user
Quote this message in a reply
09-20-2017, 03:10 PM
Post: #42
RE: HHC 2017 RPN Programming contest information and results thread
After 40 years of not programming on my HP-41CX, 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)
Find all posts by this user
Quote this message in a reply
09-20-2017, 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 HP-41CX? I'd love to have that for future reference.
Find all posts by this user
Quote this message in a reply
09-20-2017, 03:32 PM
Post: #44
RE: HHC 2017 RPN Programming contest information and results thread
(09-20-2017 03:16 PM)jjohnson873 Wrote:  I'm curious. Is there a table that shows the number of bytes that each instruction takes on the HP-41CX? 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 HP-41C instruction set; all the additional functions in the CX are two bytes.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-20-2017, 03:35 PM (This post was last modified: 09-20-2017 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
Find all posts by this user
Quote this message in a reply
09-23-2017, 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
Find all posts by this user
Quote this message in a reply
09-24-2017, 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 HP-41cx.

Thanks Gene for a great contest this year!

Try CC41!
Find all posts by this user
Quote this message in a reply
10-01-2017, 09:50 PM (This post was last modified: 10-06-2017 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 re-write 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
02 CLA
03 CF 29
04 FIX 0
05 0
06 STO Z
07 LBL 01
08 RDN
09 ARCL X
10 CLX
11 LBL 04
12 ATOX
13 X=0?
14 GTO 05
15 48
16 -
17 X^2
18 +
19 GTO 04
20 LBL 05
21 SIGN
22 ST+ Z
23 X=Y?
24 GTO 03
25 RDN
26 4
27 X=/=Y? 
28 GTO 01
29 "UN"
30 LBL 03
31 |- "HAPPY "
32 ARCL Z
33 FIX 4
34 SF 29
35 AVIEW
36 END

69 bytes, no registers

Dave - My mind is going - I can feel it.
Find all posts by this user
Quote this message in a reply
10-01-2017, 11:14 PM (This post was last modified: 10-01-2017 11:16 PM by Don Shepherd.)
Post: #49
RE: HHC 2017 RPN Programming contest information and results thread
(10-01-2017 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.
Find all posts by this user
Quote this message in a reply
10-02-2017, 07:30 PM (This post was last modified: 10-06-2017 06:31 PM by Jeff O..)
Post: #50
RE: HHC 2017 RPN Programming contest information and results thread
Answering my own questions:
(10-01-2017 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.
(10-01-2017 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.
Find all posts by this user
Quote this message in a reply
Post Reply 




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