Post Reply 
2024 HHC Programming Contest - RPN #1
09-21-2024, 03:25 PM
Post: #1
2024 HHC Programming Contest - RPN #1
Here is the RPN programming contest #1 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 1 v1.1.pdf (Size: 87.07 KB / Downloads: 242)
Find all posts by this user
Quote this message in a reply
09-21-2024, 11:26 PM
Post: #2
RE: 2024 HHC Programming Contest - RPN #1
  • 13 bytes on the 42S using a moderately naïve approach and only 41 instructions.
  • 13 bytes using a weird approach that uses a non-41 instruction.
  • 11 bytes using a less direct but still fairly obvious approach, again on the 42S but only using 41 instructions.
  • 9 bytes using a direct approach, only using 41 instructions.

I'm not sure that the last can be beaten or by how much. At least 5 bytes are consumed by the label and the three 7s.

Pauli
Find all posts by this user
Quote this message in a reply
09-22-2024, 12:07 AM
Post: #3
RE: 2024 HHC Programming Contest - RPN #1
(09-21-2024 03:25 PM)Gene Wrote:  PLEASE do not post any solutions until 6am CENTRAL USA time MONDAY 9/23/2024.

Gene, Thank you for posting! I enjoy collaborating and learning from these fun challenges. For the sake of bounding the run-time is there an upper-bound on the max(X,Y) for the 2 inputs?

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

Find all posts by this user
Quote this message in a reply
09-22-2024, 01:07 AM
Post: #4
RE: 2024 HHC Programming Contest - RPN #1
Let's say less than 50,000.
Find all posts by this user
Quote this message in a reply
09-22-2024, 03:01 AM
Post: #5
RE: 2024 HHC Programming Contest - RPN #1
(09-21-2024 11:26 PM)Paul Dale Wrote:  
  • 13 bytes on the 42S using a moderately naïve approach and only 41 instructions.
  • 13 bytes using a weird approach that uses a non-41 instruction.
  • 11 bytes using a less direct but still fairly obvious approach, again on the 42S but only using 41 instructions.
  • 9 bytes using a direct approach, only using 41 instructions.

I'm not sure that the last can be beaten or by how much. At least 5 bytes are consumed by the label and the three 7s.

Pauli

On the 41C, are you sure you are counting the two bytes of LBL A and the three bytes of END?
Find all posts by this user
Quote this message in a reply
09-22-2024, 03:05 AM
Post: #6
RE: 2024 HHC Programming Contest - RPN #1
Yes.
Find all posts by this user
Quote this message in a reply
09-22-2024, 04:50 AM
Post: #7
RE: 2024 HHC Programming Contest - RPN #1
Not sure, I'm doing this on a 42S and reporting it's byte counts.
So probably not.
Find all posts by this user
Quote this message in a reply
09-22-2024, 10:11 AM
Post: #8
RE: 2024 HHC Programming Contest - RPN #1
(09-22-2024 04:50 AM)Paul Dale Wrote:  Not sure, I'm doing this on a 42S and reporting it's byte counts.
So probably not.

I call shenanigans Smile

LBL A is 2 bytes
Three 7s are 3 bytes.
END is 3 bytes.

There is no way you can get to 24 with just one 1-byte instruction. Proof by exhaustive search!

/ji

FWIW, the SHA256 hash of my solution is:
Code:

d91bda1c26722c52c271db49a2805b97e93049120c8c4e1a2d6fe715a6dc1409  hhc24rpn1.txt

I'll post it when the competition ends.
Find all posts by this user
Quote this message in a reply
09-22-2024, 10:21 AM (This post was last modified: 09-22-2024 01:50 PM by C.Ret.)
Post: #9
RE: 2024 HHC Programming Contest - RPN #1
(09-22-2024 01:07 AM)Gene Wrote:  
(09-22-2024 12:07 AM)Allen Wrote:  Gene, Thank you for posting! I enjoy collaborating and learning from these fun challenges. For the sake of bounding the run-time is there an upper-bound on the max(X,Y) for the 2 inputs?
Let's say less than 50,000.
Bonjour,

Tonight I'm going to spend some quality time trying to solve them. I'm not at all sure that I'll find an effective solution to each of them, but the little practices will be good enough and a lot of fun. I am a great fan of Rule#13.

But this question concerning (X,Y) and its answer, would they not be at a better place in the subject concerning the 2024 HHC Programming Contest - RPL?
Find all posts by this user
Quote this message in a reply
09-22-2024, 09:12 PM
Post: #10
RE: 2024 HHC Programming Contest - RPN #1
(09-22-2024 10:21 AM)C.Ret Wrote:  But this question concerning (X,Y) and its answer, would they not be at a better place in the subject concerning the 2024 HHC Programming Contest - RPL?

Thank you for catching that..I"ve posted the question and answer there. I'm actually relived after thinking about the RPN problem, I was impressed, and speechless that Mr. Dale could generate a 9-byte solution to the RPL challenge I was reading!! Thank you for the correction!

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

Find all posts by this user
Quote this message in a reply
09-22-2024, 11:56 PM
Post: #11
RE: 2024 HHC Programming Contest - RPN #1
HP33C - I don't have an HP41C

Just using simple addition stack operations etc.

Seems to use 12 bytes (technically 24 nibbles) - No LBL or END as HP33C does not have these instructions.

I look forward to seeing the other solutions!

Mike T.

HP21, HP25, HP32E, HP33C, HP34C, HP10C, HP11C, HP12C, HP32S, HP22S
Find all posts by this user
Quote this message in a reply
09-23-2024, 03:58 AM
Post: #12
RE: 2024 HHC Programming Contest - RPN #1
13 bytes.

It would be 10 bytes if I didn’t have to use the third 7

Dejqn
Find all posts by this user
Quote this message in a reply
09-23-2024, 06:21 AM (This post was last modified: 09-23-2024 07:37 AM by ThomasF.)
Post: #13
RE: 2024 HHC Programming Contest - RPN #1
Thanks for the challenge Gene!

LBL A - 2 bytes
END - 3 bytes
3 times 7's - 3 bytes --> so 8 bytes just for the framework (unless the numeric 7's ends up elsewhere ... Wink)

I got two similar approaches - both 7 lines - and both ending up with 12 bytes in total and with 24 in the display - but still far from the 9 bytes ... Wink

EDIT: Correction - Solution 1: 7 lines, solution 2: 6 lines, but both 12 bytes in total.

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
09-23-2024, 07:17 AM (This post was last modified: 09-23-2024 08:08 AM by J-F Garnier.)
Post: #14
RE: 2024 HHC Programming Contest - RPN #1
A somehow inelegant solution (although eligible I hope).
12 bytes including the END (not .END. !) on a 41CX, confirmed by the CAT 1 output on a (virtual) printer:
Code:
END       12 BYTES

Edit: my solution has 6 steps.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
09-23-2024, 07:52 AM (This post was last modified: 09-23-2024 07:52 AM by Didier Lachieze.)
Post: #15
RE: 2024 HHC Programming Contest - RPN #1
12 bytes also here. (7 steps including LBL A and END)
Find all posts by this user
Quote this message in a reply
09-23-2024, 09:26 AM (This post was last modified: 09-23-2024 09:28 AM by Harald.)
Post: #16
RE: 2024 HHC Programming Contest - RPN #1
I am struggling. How do you guys do this on a 42s? How do I enter "LBL A" without pressing the "3" key?

Edit: nevermid, forgot that "Catalog" is on the "+"
Find all posts by this user
Quote this message in a reply
09-23-2024, 10:05 AM
Post: #17
RE: 2024 HHC Programming Contest - RPN #1
(09-23-2024 09:26 AM)Harald Wrote:  How do I enter "LBL A" without pressing the "3" key?

Hi Harald,

Remember that pressing the "3" key is not necessarily a numeric digit entry and still valid, as the example that Gene gave in the contest description:
Quote:If you decided you simply had to use Shift 4 to use BEEP in the routine, that is permissible since the 4 is not a
true digit, but I don’t know why you would do that.

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
09-23-2024, 10:31 AM
Post: #18
RE: 2024 HHC Programming Contest - RPN #1
I guess it is ok to post solutions now…

My solution is basically 77 TAN INT FACT. Since I need to use third 7, it is something like

LBL A
7
ENTER
77
TAN
INT
fACT
END


Dejan
Find all posts by this user
Quote this message in a reply
09-23-2024, 11:03 AM
Post: #19
RE: 2024 HHC Programming Contest - RPN #1
I ended up with 3 similar solutions, all using 12 bytes ...

Code:
01 LBL A   2   LBL A   2   LBL A   2
02 77E7    4   777     3   77      2
03 LN      1   R-D     1   LN      1
04 INT     1   LOG     1   7       1
05 OCT     1   INT     1   *       1
06 END     3   FACT    1   INT     1
07             END     3   DEC     1
08                         END     3
          12 bytes    12 bytes    12 bytes

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
09-23-2024, 11:04 AM (This post was last modified: 09-23-2024 11:50 AM by Gene.)
Post: #20
RE: 2024 HHC Programming Contest - RPN #1
Here are the solutions from the conference:

17 bytes:

LBL A 7 e^X SQRT INT 7 - 7 ENTER / ENTER + - END


16 bytes:

LBL A 7 ENTER 7 ENTER 7 + + LN LASTX + INT END

LBL A CLΣ Σ+ Σ+ Σ+ ENTER 7 + 7 + 7 + END

LBL A 7 ENTER 7 + 7 + STO Y LASTX / + END


14 bytes:

LBL A 7 ENTER 7 ÷ 7 % ATAN INT FACT END

LBL A 7 ENTER 77 LN INT * LASTX - END


13 bytes:

LBL A 777 ENTER COS % INT FACT END

LBL A 7 ENTER 7 + 7 ÷ x^2 FACT END

LBL A 77 ENTER 7 P->R e^x INT FACT


12 bytes:

LBL A COS ATAN 7 - 7 - 7 - END

LBL A 7 Sigma+ 7 Sigma+ 7 Sigma+ RCL 11 END

LBL A 777 LOG INT x^2 FACT END

LBL A 77 TAN INT FACT 7 X<>Y END

LBL A 777 LOG LOG ATAN INT END

LBL A 77.7 TAN INT FACT END




What I love are the wide varieties of the solutions. P->R ? OCT ? :-)

Is there an 11 byte solution given the LBL A and END ?
Find all posts by this user
Quote this message in a reply
Post Reply 




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