Post Reply 
HHC 2021 Programming Contests - Surprise !
10-21-2021, 09:17 AM (This post was last modified: 10-25-2021 02:08 PM by Werner.)
Post: #41
RE: HHC 2021 Programming Contests - Surprise !
Update 20211025: yet another correction.... hopefully the last one! 88 bytes on the 41.
Corrected version.. 42S-style listing, even shorter ;-)
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.
Code:
00 { 96-Byte Prgm }
01▸LBL "PAL"
02 FIX 00
03 CF 29
04 1
05 +
06 CLA
07 ARCL ST X
08 XEQ 14
09 ALENG
10 2
11 MOD
12 X=0?
13 GTO 00
14 -
15▸LBL 02
16 1
17 +
18 10
19 ÷
20 IP
21 LASTX
22 XEQ 10
23 X<Y?
24 GTO 02
25 RTN
26▸LBL 00
27 SIGN
28 -
29▸LBL 03
30 1
31 +
32 10
33 %
34 XEQ 10
35 X<Y?
36 GTO 03
37 RTN
@     add reverse digits of number
38▸LBL 10
39 ENTER
40 FP
41 STO+ ST Z
42 -
43 10
44 STO× ST Z
45 ÷
46 X>0?
47 GTO 10
48 +
49 X<Y?
50 X=Y?
51 RTN
52 R↓
@     leading half: abcd -> ab, abcde -> abc
53▸LBL 14
54 STO ST Y
55 ALENG
56 2
57 ÷
58 IP
59 10^X
60 ÷
61 IP
62 END
Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HHC 2021 Programming Contests - Surprise ! - Werner - 10-21-2021 09:17 AM



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