Post Reply 
HHC 2021 Programming Contests - Surprise !
10-25-2021, 02:09 PM
Post: #42
RE: HHC 2021 Programming Contests - Surprise !
I had managed to shave two steps out of my earlier versions and figured that was about the best I could do, or at least maybe the best I should do so as to stop spending time on this particular challenge. I was going to update my original listings above with the slight improvement and call things good when I saw Werner's above post:

(10-21-2021 09:17 AM)Werner Wrote:  To catch an input of all 9's, I simply add 1 to the number at the beginning, and stop if
the palindrome formed by mirroring the first half is larger or equal to the original.

I find the above to be fairly brilliant. Applying this concept to my program shaved off 19 steps. Now down to 53 steps, 86 bytes. The latest and most likely greatest (for me, at least) version is below. Handles inputs greater than or equal to 0. (I would file a protest with the proper authorities if the judge used a negative number as a test case.)

Code:
00 { 86-Byte Prgm }
01▸LBL "PAL"
02 FIX 00
03 CF 29
04 CF 01
05 CLA
06 1
07 +
08 STO 01
09 ARCL ST X
10 ALENG
11 2
12 ÷
13 FP
14 X≠0?
15 SF 01
16 X<>Y
17 LASTX
18 IP
19 10^X
20 ÷
21 IP
22 STO 03
23 XEQ 50
24 RCL 01
25 X<>Y
26 X≥Y?
27 STOP
28 RCL 03
29 1
30 +
31 XEQ 50
32 STOP
33▸LBL 50
34 0.1
35 RCL× ST Y
36 ENTER
37 FC? 01
38 RCL ST Z
39 IP
40▸LBL 01
41 10
42 STO× ST Z
43 ÷
44 X=0?
45 GTO 00
46 ENTER
47 FP
48 STO+ ST Z
49 -
50 GTO 01
51▸LBL 00
52 R↓
53 END

Dave - My mind is going - I can feel it.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HHC 2021 Programming Contests - Surprise ! - Jeff O. - 10-25-2021 02:09 PM



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