Post Reply 
HHC 2021 Programming Contests - Surprise !
10-07-2021, 10:50 PM (This post was last modified: 10-07-2021 10:51 PM by Craig Bladow.)
Post: #28
RE: HHC 2021 Programming Contests - Surprise !
Here is my second place entry in the HHC 2021 RPN contest. As submitted it was 72 bytes. I removed the STOP at the end so as presented here it is 71 bytes.
My strategy was to get something working, with some efficiency, and then reduce the program size. My approach compared each digit with its match until failure, so it would not spend time reversing the entire number for every candidate. Also only the first odd number of digits, greater than N/2 (N is the number of digits), would be compared.

Very late Saturday I had achieved the first two goals but ran out of time to try any new approaches. Sad

Code:

01▸LBL "PAL"
02 STO 00
03 FIX 00
04 CF 29
05▸LBL 00
06 1
07 STO+ 00
08 RCL 00
09 CLA
10 ARCL ST X
11 ALENG
12 2
13 ÷
14 IP
15 1
16 -
17 X<0?
18 GTO 02
19 1ᴇ3
20 ÷
21 STO 01
22 X<>Y
23 STO 02
24▸LBL 01
25 RCL 02
26 10
27 ÷
28 IP
29 STO 02
30 LASTX
31 FP
32 10

But did I develop the faster solution? Wink

I keyed in David Hayden's excellent first place solution, which is a very elegant and compact program and ran Gene's 15151 test number as input.

The above routine took 16 seconds to find the next palindrome and David's winning solution took 24 seconds, on the same DM41X, in fast mode, on battery power.

So a small consolation! Smile

Try CC41!
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HHC 2021 Programming Contests - Surprise ! - Craig Bladow - 10-07-2021 10:50 PM



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