Post Reply 
2023 RPN HHC Programming Contest
10-08-2023, 03:22 PM (This post was last modified: 10-08-2023 03:26 PM by ThomasF.)
Post: #21
RE: 2023 RPN HHC Programming Contest
(10-08-2023 02:58 PM)Ajaja Wrote:  
Code:
You may not use the EEX key.
Oops...
Assuming HP-41C with broken keyboard without keys 0-9 and EEX (for "P" in alpha mode, e.g.), it wouldn't be possible to enter my solution. So, maybe it's not valid after all.

No, you could enter "P" if you want to.

As Gene wrote: "... and to challenge getting a couple of specific numbers without using digit keys to help out.", you are not allowed to enter a digit as in a number or as an argument, i.e "FIX 4".
But the keys still work, so you could enter SHIFT + EEX --> RTN, or alpha "P", or SHIFT + 4 --> BEEP as in an previous example.

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
10-08-2023, 03:22 PM
Post: #22
RE: 2023 RPN HHC Programming Contest
Yes, pressing a key as a press of a digit is allowable as long as it does not reference a data memory OR enter a direct numeric value into a program line.

Exceptions such as 1/x, etc are fine.
Find all posts by this user
Quote this message in a reply
10-08-2023, 03:50 PM
Post: #23
RE: 2023 RPN HHC Programming Contest
(10-08-2023 02:07 PM)Gene Wrote:  Remember, we all want to learn and have fun :-)

It has indeed been both. I used to do a LOT of RPN programming until I sold my CX to buy a 28c when it came out. I've been an RPL guy since, but I found this particular contest challenge rather intriguing, enough for me to dust off my CV and give it a try.

Gene, thanks so much for posting it. I look forward to seeing everyone's solutions tomorrow.
Find all posts by this user
Quote this message in a reply
10-08-2023, 04:53 PM
Post: #24
RE: 2023 RPN HHC Programming Contest
12 steps, 20 bytes.
Find all posts by this user
Quote this message in a reply
10-08-2023, 07:13 PM (This post was last modified: 10-08-2023 07:15 PM by Wes Loewer.)
Post: #25
RE: 2023 RPN HHC Programming Contest
(10-08-2023 04:53 PM)Gerson W. Barbosa Wrote:  12 steps, 20 bytes.

I should probably know this, but how do you find the byte count on the 41? I've searched to no avail.
Free42 says that my 12 steps are 17 bytes.
Find all posts by this user
Quote this message in a reply
10-08-2023, 07:19 PM
Post: #26
RE: 2023 RPN HHC Programming Contest
On the HP-41CX, do a shift CAT 1 and R/S when the HHC label is shown. While that is in the display, press SST once and it should show END on the left side and the byte count on the right.

Best to do a Shift GTO . . to put an END at the bottom of the program and remove any NULLs from editing first.
Find all posts by this user
Quote this message in a reply
10-08-2023, 07:20 PM
Post: #27
RE: 2023 RPN HHC Programming Contest
(10-08-2023 04:53 PM)Gerson W. Barbosa Wrote:  12 steps, 20 bytes.

Same here, first full working version 12 steps (14 including label and END), 20 bytes

I have an evening activity which my body will be attending, but my mind will be in the PRG menu.

17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b

Find all posts by this user
Quote this message in a reply
10-08-2023, 07:53 PM
Post: #28
RE: 2023 RPN HHC Programming Contest
(10-08-2023 07:13 PM)Wes Loewer Wrote:  
(10-08-2023 04:53 PM)Gerson W. Barbosa Wrote:  12 steps, 20 bytes.

I should probably know this, but how do you find the byte count on the 41? I've searched to no avail.
Free42 says that my 12 steps are 17 bytes.

I have a 41C and a 41CV, on which CAT 1 does not give the size information. I would attach the infrared module and do CAT 1 in TRACE mode, but it’s easier to use the i41CX+ emulator.

By the way, I get 17 bytes on the HP-42S as well. It preserves the original X register content. No fancy instructions, it should work also on the HP-11C and HP-15C. Plain numerical listings though :-)
Find all posts by this user
Quote this message in a reply
10-08-2023, 08:05 PM
Post: #29
RE: 2023 RPN HHC Programming Contest
(10-08-2023 04:53 PM)Gerson W. Barbosa Wrote:  12 steps, 20 bytes.

Wow, that is impressive!

10 bytes for LBL and END, gives 10 bytes for 10 lines, so only 10 one byte instructions! Wink

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
10-08-2023, 08:24 PM
Post: #30
RE: 2023 RPN HHC Programming Contest
(10-08-2023 07:19 PM)Gene Wrote:  On the HP-41CX, do a shift CAT 1 and R/S when the HHC label is shown. While that is in the display, press SST once and it should show END on the left side and the byte count on the right.

Thanks. I tried it out on the V41 emulator and the 12 steps (including LBL and END) show 20 bytes.
Find all posts by this user
Quote this message in a reply
10-08-2023, 08:31 PM
Post: #31
RE: 2023 RPN HHC Programming Contest
19 bytes, 11 lines
W.

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
10-08-2023, 08:41 PM
Post: #32
RE: 2023 RPN HHC Programming Contest
(10-08-2023 08:05 PM)ThomasF Wrote:  
(10-08-2023 04:53 PM)Gerson W. Barbosa Wrote:  12 steps, 20 bytes.

Wow, that is impressive!

10 bytes for LBL and END, gives 10 bytes for 10 lines, so only 10 one byte instructions! Wink

Thanks, Thomas.

Yes, only one-byte instructions available on most scientific HP calculators. Anyway only a couple a bytes shorter than your current solution.
As I wasn’t getting any improvement, I decided to change the approach, but only slightly.
I’m looking forward to your and others’ solutions. Hopefully someone comes up with a really outstanding one, mine is rather straightforward.

Best regards,

Gerson.
Find all posts by this user
Quote this message in a reply
10-08-2023, 09:21 PM (This post was last modified: 10-08-2023 09:24 PM by Peet.)
Post: #33
RE: 2023 RPN HHC Programming Contest
I am very curious to see some solutions, I tried and my attempt has 12 lines, 20 byte (HP41, with lbl and end).
Y: 71
X: 41
L: 41,8584

My calculators - former: CBM PR100, HP41CV, HP11C, HP28S - current: HP48G, HP35S, Prime, DM41X, DM42, HP12C
Find all posts by this user
Quote this message in a reply
10-09-2023, 12:10 AM
Post: #34
RE: 2023 RPN HHC Programming Contest
Preliminary 18-byte program (12 steps with label and end) Note: Byte count is in Free42 and may differ slightly in the plain 41C.

Code:

00 { 18-Byte Prgm }
01>LBL "HHC"
02 PI
03 IP
04 ATAN
05 IP
06 RCL ST X
07 LASTX
08 FP
09 ATAN
10 -
11 IP
12 .END.

17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b

Find all posts by this user
Quote this message in a reply
10-09-2023, 12:11 AM
Post: #35
RE: 2023 RPN HHC Programming Contest
(10-08-2023 08:31 PM)Werner Wrote:  19 bytes, 11 lines
W.

Ditto!
Find all posts by this user
Quote this message in a reply
10-09-2023, 12:51 AM
Post: #36
RE: 2023 RPN HHC Programming Contest
Code:
01▸LBL "HHC"
02 SIGN
03 ENTER↑
04 XEQ A
05 XEQ A
06▸LBL A
07 +
08 ST+ L
09 LASTX
10 ST+ Y
11 END
26 Bytes

It calculates A254308: 1, 1, 2, 3, 5, 8, 11, 19, 30, 41, 71
Find all posts by this user
Quote this message in a reply
10-09-2023, 01:11 AM
Post: #37
RE: 2023 RPN HHC Programming Contest
Code:

 01 LBL "HHC"
 02 PI
 03 1/X
 04 ACOS
 05 INT
 06 PI
 07 LN
 08 1/X
 09 ATAN
 10 INT
 11 END

19 bytes

Code:

 01 LBL "HHC"
 02 PI
 03 INT
 04 ATAN
 05 INT
 06 LASTX
 07 PI
 08 INT
 09 SQRT
 10 /
 11 INT
 12 END

20 bytes
Find all posts by this user
Quote this message in a reply
10-09-2023, 03:10 AM
Post: #38
RE: 2023 RPN HHC Programming Contest
(10-09-2023 12:10 AM)Allen Wrote:  Preliminary 18-byte program (12 steps with label and end) Note: Byte count is in Free42 and may differ slightly in the plain 41C.

Code:

00 { 18-Byte Prgm }
01>LBL "HHC"
02 PI
03 IP
04 ATAN
05 IP
06 RCL ST X
07 LASTX
08 FP
09 ATAN
10 -
11 IP
12 .END.

Yes, on the HP-41 the number of bytes is 21. So 10 instructions and 11 bytes not considering LBL and END. All one-byte instructions except for the necessary RCL ST X. Anyway, it’s difficult to do it in 12 steps using this approach (an approximation for 41 or 71, the other obtained through the 30 units difference). Congratulations for managing to save two steps in your previous code!

Gerson.
Find all posts by this user
Quote this message in a reply
10-09-2023, 03:14 AM (This post was last modified: 10-09-2023 03:43 AM by Wes Loewer.)
Post: #39
RE: 2023 RPN HHC Programming Contest
Good job to those of you who got it down to 11 lines / 19 bytes.
Our similarly sized programs are more different that I anticipated. Here's my best at 12 lines / 20 bytes. Did anyone else think of converting between radians and degrees and between octal and decimal? The numbers just happen to work out pretty well.

Code:
01 LBL "HHC"
02 SIGN     { 1 }
03 R-D      { 57.29 } 
04 INT      { 57 }
05 OCT      { 71 }
06 LASTX    { 57 71 }
07 DEC      { 47 71 }
08 ENTER↑   { 47 47 71 }
09 SQRT     { 6.85 47 71 }
10 INT      { 6 47 71 }
11 -        { 41 71 }
12 END

or using the 42 command names
Code:
01▸LBL "HHC"
02 SIGN
03 →DEG
04 IP
05 →OCT
06 LASTX
07 →DEC
08 ENTER
09 SQRT
10 IP
11 -
12 END
Find all posts by this user
Quote this message in a reply
10-09-2023, 04:27 AM
Post: #40
RE: 2023 RPN HHC Programming Contest
My best:
Code:
01 LBL "HHC"
02 PI
03 INT
04 ATAN
05 INT      # 71 on stack here
06 PI
07 x^2
08 FRAC
09 ATAN
10 INT      # 41 on stack here
11 .END.

I think this is equal to the previous best.


I found one other approach for the first half 71, but I don't consider it as pure since it relies on a zero on the stack:
Code:

ACOS ->DEG SQRT INT

I did find two equal length alternative solutions for the second half 41:
Code:

PI PI ->POL INT - 
PI ->H 10^x SQRT INT

Since I was using my 11c for this, I did locate a neat solution for 41, but not suitable for the 41, because it requires gamma:
Code:

PI LOG x! ATAN INT

On the 11c there is a single step shorter solution available but, sadly, also not available on the 41 due to the use of an hyperbolic function. The first step is quite malleable, there being multiple alternatives to get 1 on the stack: x!, 10^x or EXP are equally good.
Code:

COS ASINH ATAN INT


I didn't properly investigate deriving 41 from 71 or viceversa but the best I could manage wasn't shorter. For example (with 71 on the stack and the prior value in last x):
Code:

LASTx SIN x^2 ATAN INT

Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 




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