Post Reply 
HHC 2021 Programming Contests - Surprise !
10-06-2021, 05:35 PM
Post: #24
RE: HHC 2021 Programming Contests - Surprise !
Just finished my RPN program using the exact same algorithm Dave just explained ;-)
It doesn't use any synthetics or CX commands. The listing is in 42S code, the corresponding 41 code is 88 bytes without the END. Stack-only, of course ;-)
There's probably room for improvement..

Code:
00 { 95-Byte Prgm }
01▸LBL "PAL"
02 FIX 00
03 CF 29
04 CLA
05 ARCL ST X
06 XEQ 14
07 ALENG
08 2
09 MOD
10 X=0?
11 GTO 03
12 CLX
13▸LBL 02
14 +
15 10
16 ÷
17 IP
18 LASTX
19 XEQ 10
20 X>Y?
21 RTN
22 R↓
23 XEQ 14
24 1
25 GTO 02
26▸LBL 03
27 +
28 10
29 %
30 XEQ 10
31 X>Y?
32 RTN
33 R↓
34 XEQ 14
35 1
36 GTO 03
@  add reverse digits of number
37▸LBL 10
38 ENTER
39 FP
40 STO+ ST Z
41 -
42 10
43 STO× ST Z
44 ÷
45 X>0?
46 GTO 10
47 +
48 RTN
@  leading half: abcd -> ab, abcde -> abc
49▸LBL 14
50 STO ST Y
51 ALENG
52 2
53 ÷
54 IP
55 10^X
56 ÷
57 IP
58 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-06-2021 05:35 PM



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