Post Reply 
2023 RPN HHC Programming Contest
10-16-2023, 03:37 AM
Post: #61
RE: 2023 RPN HHC Programming Contest
(10-16-2023 02:31 AM)Allen Wrote:  indeed.. the others are less practical as they require too many terms for a short program!

Meanwhile, by using a(n) = n² + n - 1, for n = 6, 8 instead, I was able to save one more byte:

Code:

 01 LBL "HHC"
 02 PI
 03 X^2
 04 INT
 05 XEQ 00
 06 LASTX
 07 LBL 00
 08 DSE X
 09 X^2
 10 LASTX
 11 DSE X
 12 +
 13 END

13 steps, 25 bytes.

Or, back to a(n) = n² - n - 1, for n = 7, 9 and assuming a positive number in stack register X, one more step can be saved:

Code:

 01 LBL "HHC"
 02 SIGN
 03 10^X
 04 XEQ 00
 05 LASTX
 06 LBL 00
 07 DSE X
 08 ENTER
 09 DSE X
 10 *
 11 DSE X
 12 END

12 steps, 25 bytes.
Find all posts by this user
Quote this message in a reply
10-21-2023, 03:56 PM (This post was last modified: 10-21-2023 04:04 PM by Craig Bladow.)
Post: #62
RE: 2023 RPN HHC Programming Contest
Here is my 24 byte program which tied for first place with Jason's program. CC41 was quite helpful in the program development process.

Code:

@ HHC 2023 Contest Entry 41/71
LBL "HHC"
SIGN
10^X
ENTER
ENTER
+
+
LASTX
SIGN
LASTX
+
LASTX
+
+
LASTX
END

Try CC41!
Find all posts by this user
Quote this message in a reply
10-21-2023, 07:26 PM
Post: #63
RE: 2023 RPN HHC Programming Contest
Craig,
Thank you for the interesting CC41 program and congrats on the solution at the conference! I really love the "load and run this program on start"!! On the face that seems really handy, and I was preparing to do on the computer what I've been doing by hand the last week or so, until...

There are a few small behaviors that are somewhat different than a normal 41C would do:

Code:
> pi     x: 3.1416 y:50.0000 z:0.0000 t:32.0000 l:50.0000 a:
> cos     x: 0.9985 y:50.0000 z:0.0000 t:32.0000 l:3.1416 a:
> isg x   x: 49.9985 y:50.0000 z:0.0000 t:32.0000 l:3.1416 a:
> dec   x: 40.0000 y:50.0000 z:0.0000 t:32.0000 l:49.9985 a:

(this is correct for input of 50.0000, but 49.9985 should say "DATA ERROR" and leave x value unchanged?)

or
Code:
> pi     x: 3.1416 y:0.0000 z:41.0000 t:50.0000 l:49.0000 a:
> cos     x: 0.9985 y:0.0000 z:41.0000 t:50.0000 l:3.1416 a:
> isg x     x: 49.9985 y:0.0000 z:41.0000 t:50.0000 l:3.1416 a:
> int     x: 49.0000 y:0.0000 z:41.0000 t:50.0000 l:49.9985 a:
> dec     x: 0.0000 y:0.0000 z:41.0000 t:50.0000 l:49.0000 a:

(0.00 is not a valid oct to dec conversion for anything except input of 0.000 . should say "DATA ERROR" and leave x value unchanged?)

Neither of these x values would be allowed without error checking the OCT->DEC command for integer input not containing the '9' digit in the base10 number. the DEC->OCT command does not have the numerical restriction, but should check for integer input.
Code:
> 5.5     x: 5.5000 y:0.0000 z:0.0000 t:41.0000 l:49.0000 a:
> oct     x: 6.0000 y:0.0000 z:0.0000 t:41.0000 l:5.5000 a:

should also return error and leave x value unchanged?

I confess I've only looked at it for a few minutes, so if this is something clearly addressed in the nicely written manual (which I did search for notes on OCT and DEC behaviors) , it is my own lack of reading and I apologize in advance.

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-21-2023, 10:25 PM
Post: #64
RE: 2023 RPN HHC Programming Contest
Allen,

Thanks for trying CC41. I'll reply to your post in this thread regarding CC41.

Cheers,
Craig

Try CC41!
Find all posts by this user
Quote this message in a reply
10-23-2023, 06:51 PM
Post: #65
RE: 2023 RPN HHC Programming Contest
Here's my 3rd place entry at 25 bytes.
Code:
01 LBL "HHC"
02 ∑+
03 ENTER↑
04 10↑X
05 ENTER↑
06 ∑+
07 1/X
08 ACOS
09 LASTX
10 ASIN
11 RDN
12 +
13 +
14 ENTER↑
15 R↑
16 -
17 END
I love these contests. It's fun to do them at the conference, but the really great part is seeing how the forum always comes up with a much better solution. Many thanks to Gene for creating and judging them.

Dave
Find all posts by this user
Quote this message in a reply
10-26-2023, 08:07 PM
Post: #66
RE: 2023 RPN HHC Programming Contest
(10-23-2023 06:51 PM)David Hayden Wrote:  Here's my 3rd place entry at 25 bytes.
Code:
01 LBL "HHC"
02 ∑+
03 ENTER↑
04 10↑X
05 ENTER↑
06 ∑+
07 1/X
08 ACOS
09 LASTX
10 ASIN
11 RDN
12 +
13 +
14 ENTER↑
15 R↑
16 -
17 END
I love these contests. It's fun to do them at the conference, but the really great part is seeing how the forum always comes up with a much better solution. Many thanks to Gene for creating and judging them.

Thank you for posting your code. It’s always interesting to see the various approaches to the problem. My first attempt was also 25-byte and 17-step long, based on an easy to find approximation, which was subsequently reduced to the 24-byte 16-step one I first mentioned. I remember having used both ∑+ and ∑- in a past contest, when it was already over, I think.
Trying these at home with lots of free time is quite a different thing than solving them at the conference while participating in various activities, though.
Just for the record, before I throw away my notes, I will leave below my first two attempts.
Also, I tried a small variation on Gene’s challenge. Instead of placing 71 and 41 on the stack, I thought of displaying just a single constant, 7141. I imagined it could be done using fewer steps, but I didn’t find anything shorter than 13 steps on the 41C (or 18 bytes and 12 steps on the HP-42S, by loosening the rules to allow a 42S-specific feature, but not ATOX).

Best regards,

Gerson.

——

Code:


 01 LBL "HHC"
 02 PI
 03 SQRT
 04 LASTX
 05 E^X
 06 *
 07 INT
 08 PI
 09 INT
 10 SQRT
 11 X<>Y
 12 *
 13 LASTX
 14 X<>Y
 15 INT
 16 X<>Y
 17 END

25 bytes

Code:


 01 LBL "HHC"
 02 PI
 03 INT
 04 SQRT
 05 PI
 06 E^X
 07 LASTX
 08 SQRT
 09 *
 10 *
 11 LASTX
 12 X<>Y
 13 INT
 14 X<>Y
 15 INT
 16 END 

24 bytes
Find all posts by this user
Quote this message in a reply
10-26-2023, 08:47 PM (This post was last modified: 10-26-2023 08:47 PM by Paul Dale.)
Post: #67
RE: 2023 RPN HHC Programming Contest
Gerson's challenge to get 7141 can be done in 7 steps:

PI LN ->H LOG ACOS x^2 INT


Pauli
Find all posts by this user
Quote this message in a reply
10-26-2023, 09:11 PM (This post was last modified: 10-26-2023 09:11 PM by Gerson W. Barbosa.)
Post: #68
RE: 2023 RPN HHC Programming Contest
(10-26-2023 08:47 PM)Paul Dale Wrote:  Gerson's challenge to get 7141 can be done in 7 steps:

PI LN ->H LOG ACOS x^2 INT


Indeed! I would need pi/2 times more steps. Perhaps I should have suggested the more appropriate 4241 which can be done in 6 steps on the 42S, excluding LBL and END :-)
(That would depend on a positive number on the stack, though)
Find all posts by this user
Quote this message in a reply
10-26-2023, 11:41 PM (This post was last modified: 10-27-2023 06:14 PM by Gerson W. Barbosa.)
Post: #69
RE: 2023 RPN HHC Programming Contest
(10-26-2023 09:11 PM)Gerson W. Barbosa Wrote:  
(10-26-2023 08:47 PM)Paul Dale Wrote:  Gerson's challenge to get 7141 can be done in 7 steps:

PI LN ->H LOG ACOS x^2 INT


Indeed! I would need pi/2 times more steps.

HP-41C:

Code:

 01 LBL "ABC"
 02 SIGN
 03 ST+ X
 04 1/X
 05 ACOS
 06 X^2
 07 PI
 08 INT
 09 X^2
 10 X^2
 11 +
 12 OCT
 13 END

HP-42S:

Code:

00 { 18-Byte Prgm }
01▸LBL "ABC"
02 PI
03 IP
04 X↑2
05 LASTX
06 SQRT
07 ATAN
08 COMPLEX
09 ABS
10 X↑2
11 →OCT
12 END

For some reason on Free42 (3.0.21) it stops at step 11 with an error message (Invalid Data).

P.S.: On Free42 the result at step 10 is 3680.999999999999999999999999999995 instead of 3681. →OCT requires an integer argument. That’s an example of a program that works on the HP-42S but not on Free42 because the internal results are not rounded to the number of digits of the display like on the latter.
Find all posts by this user
Quote this message in a reply
Post Reply 




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