Post Reply 
2023 HHC RPL Programming Contest
10-07-2023, 01:01 PM
Post: #1
2023 HHC RPL Programming Contest
Please DO NOT POST solutions here until after 6pm EASTERN time Sunday 10/8/2023.


Attached File(s)
.pdf  HHC 2023 RPL Programming Contest.pdf (Size: 66.41 KB / Downloads: 123)
Find all posts by this user
Quote this message in a reply
10-08-2023, 11:20 PM
Post: #2
RE: 2023 HHC RPL Programming Contest
I have 3 versions, tested on the HP 50G
solution = 381654729

First solution
Code:

« { 1 0 0 0 0 0 0 0 0 } 121252121 2 9
  FOR I
    IF I 1 ==
    THEN 2 'I' STO 8 ALOG / IP SWAP DROP DUP 8 ALOG * 121252121 + { 0 0 0 0 0 0 0 0 0 } ROT 1 + 1 PUT SWAP
    END DUP 9 I - ALOG / IP DUP I MOD OVER 10 / FP 10 * 5 PICK SWAP GET OR
    IF
    THEN 10 / FP .9 ==
      IF
      THEN 9 I - ALOG 8 * - I 2 - 'I' STO DUP 8 I - ALOG / IP 10 / FP 10 * ROT OVER 0 PUT UNROT
        IF 9 ==
        THEN 8 I - ALOG 8 * - I 1 - 'I' STO
        END
        IF I
        THEN DUP 8 I - ALOG / IP 10 / FP 10 * ROT SWAP 0 PUT SWAP 8 I - ALOG +
        END
      ELSE 9 I - ALOG + I 1 - 'I' STO
      END
    ELSE 10 / FP 10 * ROT SWAP 1 PUT SWAP
    END
  NEXT SWAP DROP
»
617.5 Bytes

Second solution using user flags
Code:

« RCLF 2  #1 PUT STOF 121252121 2 9
  FOR I
    IF I 1 ==
    THEN 2 'I' STO 8 ALOG / IP DUP 8 ALOG * 121252121 + RCLF 2  #0 PUT STOF SWAP 1 + SF
    END DUP 9 I - ALOG / IP DUP I MOD OVER 10 / FP 10 * FS? OR
    IF
    THEN 10 / FP .9 ==
      IF
      THEN 9 I - ALOG 8 * - I 2 - 'I' STO DUP 8 I - ALOG / IP 10 / FP 10 * DUP CF 
        IF 9 ==
        THEN 8 I - ALOG 8 * - I 1 - 'I' STO
        END
        IF I
        THEN DUP 8 I - ALOG / IP 10 / FP 10 * CF 8 I - ALOG +
        END
      ELSE 9 I - ALOG + I 1 - 'I' STO
      END
    ELSE 10 / FP 10 * SF
    END
  NEXT 
»
558.5 Bytes

Third solution using the user flags, restoring it at the end of the program
Code:

« RCLF DUP 2  #1 PUT STOF 121252121 2 9
  FOR I
    IF I 1 ==
    THEN 2 'I' STO 8 ALOG / IP DUP 8 ALOG * 121252121 + RCLF 2  #0 PUT STOF SWAP 1 + SF
    END DUP 9 I - ALOG / IP DUP I MOD OVER 10 / FP 10 * FS? OR
    IF
    THEN 10 / FP .9 ==
      IF
      THEN 9 I - ALOG 8 * - I 2 - 'I' STO DUP 8 I - ALOG / IP 10 / FP 10 * DUP CF 
        IF 9 ==
        THEN 8 I - ALOG 8 * - I 1 - 'I' STO
        END
        IF I
        THEN DUP 8 I - ALOG / IP 10 / FP 10 * CF 8 I - ALOG +
        END
      ELSE 9 I - ALOG + I 1 - 'I' STO
      END
    ELSE 10 / FP 10 * SF
    END
  NEXT SWAP STOF
»
566 Bytes

-Edwin-
Find all posts by this user
Quote this message in a reply
10-09-2023, 11:02 AM (This post was last modified: 10-09-2023 11:04 AM by 3298.)
Post: #3
RE: 2023 HHC RPL Programming Contest
This challenge is an old one, and I remember the previous iteration pretty well as Albert Chan and I made it more spicy by running off with a variant generalized to base-N. For the original one my size-optimized UserRPL take (in post #10) was 203.5 bytes long. I also had a speed-optimized one, due to different scoring criteria. The SysRPL programs in the same post were superseded by my 145-byte improvement (in post #15). That post is also where I kicked off the base-N race.
The smallest UserRPL submission was by C.Ret (in post #11) at 147.5 or 139.5 bytes, depending on whether it's entered in approximate or exact mode. It was designed for compatibility all the way down to 28C/28S, which didn't have exact mode. On machines with this mode both variants of the program work properly, the only differences are small changes in size and speed.
C.Ret also came up with a much faster program later, but it wasn't as small. It also requires exact mode on machines that have it, otherwise the trailing period added to reals in \->STR breaks the program.

I informed Gene about this repeated challenge via PM to let him take whatever action he deems appropriate, and he replied that it was an accident facilitated by a hard drive crash erasing his files on that puzzle. The on-site participants apparently didn't remember the previous iteration, which restores fairness.

Additionally, let me mention that asking for a program taking no input at all introduces a problem: it becomes possible to pre-calculate too much (e.g. \<< 381654729. \>> is definitely not acceptable), and the line between that and acceptable programs constructing that number gets blurred. For instance, how do you feel about this?
Code:
\<<
  49 57 FOR a a CHR NEXT
  9. ROLL 7. ROLLD 8. ROLL 9. ROLLD
  8. ROLL SWAP ROT 8. ROLLD
  6. ROLL 4. ROLLD 5. ROLL 6. ROLLD
  9. \->LIST \GSLIST OBJ\->
\>>
This program generates the set of digits, swaps a few around to bring them in the correct order, and concatenates them into a number. Is the swapping part too precalculated? I can't tell.
This topic is also not new, it already happened in 2019. In the 2021 iteration of this particular puzzle the base-N generalization added an input, preventing optimization past a certain (well-defined!) point. That and the raised difficulty kept it interesting for me for a while. Unfortunately, if we could prove the conjecture that there are no solutions for bases >14, that variant would also get optimized into a simple program regurgitating precalculated results.
Find all posts by this user
Quote this message in a reply
Post Reply 




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