Post Reply 
(38G) Palindromic Partition of an Integer
11-29-2023, 12:22 PM
Post: #1
(38G) Palindromic Partition of an Integer
For integer input on HOME screen the programme P24U returns a palindromic partition in Ans & stored in L1.

Improvements welcome & definitely possible.

Code:
P24U

Ans►N:
IF Ans<10
THEN
{N}►L1:
ELSE
N:
RUN N2DS:
L2(1):
IF Ans
THEN
{Ans}►L1:
ELSE
SYSEVAL 532268:
END:
SUB L2;L2;2;12:
FOR I=1 TO SIZE(L2) STEP 1;
 L2(I):
Ans►H:
IF Ans
THEN 
IF Ans>1
THEN
11-Ans:
END:
CONCAT(L1,{Ans,10^I*H-Ans})►L1:
END:
END:
END:
REVERSE(SORT(L1))►L1: 

N2DS

Ans►T:
SYSEVAL 532278:
FOR I=1 TO INT(LOG(T)+1) STEP 1;
 T MOD 10:
CONCAT(L2,{Ans})►L2:
INT(T/10)►T:
END:
Find all posts by this user
Quote this message in a reply
Post Reply 




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