This was a bug introduced in my optimization of the code in NTYPE (wouldn't you know it?
). This number was being mistakenly classified as a "special" number because of a missing 'SWAP' (highlighted in red in the code below) and hence invoking ALGO5 which still works in this case.
d SWAP GET 0 ==
SWAP d SWAP 1 + GET 0 == OR 1 0 IFTE
NTYPE
Code:
CKSUM: # C62Fh
SIZE: 3215.5
« DUP SIZE → d n
« n ZEROLST 3 NDUPN DROP
d 1 GET d 2 GET d 3 GET d n GET @ to avoid multiple GETs
→ p1 p2 p3 d1 d2 d3 dn
« CASE
d2 2 >
dn d1 - d2 - 1 + 10 MOD AND THEN
"A1"
d1 DUP
p1 1 ROT PUT n ROT PUT 'p1' STO
d2 1 - DUP
p2 2 ROT PUT n ROT PUT 'p2' STO
dn d1 - d2 - 1 + 10 MOD DUP
p3 3 ROT PUT n ROT PUT 'p3' STO
END
d2 2 >
dn d1 - d2 - 1 + 10 MOD NOT AND THEN
"A2"
d1 DUP
p1 1 ROT PUT n ROT PUT 'p1' STO
d2 2 - DUP
p2 2 ROT PUT n ROT PUT 'p2' STO
p3 3 1 PUT n 1 PUT 'p3' STO
END
d2 2 ≤
d1 1 ≠ AND
dn d1 - 2 + 10 MOD AND THEN
"A3"
d1 1 - DUP
p1 1 ROT PUT n ROT PUT 'p1' STO
p2 2 9 PUT n 9 PUT 'p2' STO
dn d1 - 2 + 10 MOD DUP
p3 3 ROT PUT n ROT PUT 'p3' STO
END
d2 2 ≤
d1 1 ≠ AND
dn d1 - 2 + 10 MOD NOT AND THEN
"A4"
d1 1 - DUP
p1 1 ROT PUT n ROT PUT 'p1' STO
p2 2 8 PUT n 8 PUT 'p2' STO
p3 3 1 PUT n 1 PUT 'p3' STO
END
d1 1 ==
d2 0 == AND
d3 3 ≤ AND
dn d3 - 10 MOD AND THEN
"A5"
p1 2 9 PUT n 9 PUT 'p1' STO
d3 1 + DUP
p2 3 ROT PUT n ROT PUT 'p2' STO
dn d3 - 10 MOD DUP
p3 4 ROT PUT n ROT PUT 'p3' STO
END
d1 1 ==
d2 0 == AND
d3 2 ≤ AND
dn d3 - 10 MOD NOT AND THEN
"A6"
p1 2 9 PUT n 9 PUT 'p1' STO
d3 2 + DUP
p2 3 ROT PUT n ROT PUT 'p2' STO
p3 4 9 PUT n 9 PUT 'p3' STO
END
d1 1 ==
d2 2 ≤ AND
d3 4 ≥ AND
dn d3 - 10 MOD AND THEN
"B1"
d2 DUP
p1 1 1 PUT n 1 PUT 2 ROT PUT n 1 - ROT PUT 'p1' STO
d3 1 - DUP
p2 3 ROT PUT n ROT PUT 'p2' STO
dn d3 - 10 MOD DUP
p3 4 ROT PUT n ROT PUT 'p3' STO
END
d1 1 ==
d2 2 ≤ AND
d3 3 ≥ AND
dn d3 - 10 MOD NOT AND THEN
"B2"
d2 DUP
p1 1 1 PUT n 1 PUT 2 ROT PUT n 1 - ROT PUT 'p1' STO
d3 2 - DUP
p2 3 ROT PUT n ROT PUT 'p2' STO
p3 4 1 PUT n 1 PUT 'p3' STO
END
d1 1 ==
d2 3 < AND d2 0 ≠ AND
d3 2 < AND
dn 0 == AND THEN
"B3"
d2 1 - DUP
p1 1 1 PUT n 1 PUT 2 ROT PUT n 1 - ROT PUT 'p1' STO
p2 3 8 PUT n 8 PUT 'p2' STO
p3 4 1 PUT n 1 PUT 'p3' STO
END
d1 1 ==
d2 3 < AND d2 0 ≠ AND
d3 1 > AND d3 4 < AND
dn 0 == AND THEN
"B4"
d2 DUP
p1 1 1 PUT n 1 PUT 2 ROT PUT n 1 - ROT PUT 'p1' STO
p2 3 1 PUT n 1 PUT 'p2' STO
p3 4 8 PUT n 8 PUT 'p3' STO
END
d1 1 ==
d2 3 < AND d2 0 ≠ AND
d3 3 < AND
dn 0 ≠ AND THEN
"B5"
d2 1 - DUP
p1 1 1 PUT n 1 PUT 2 ROT PUT n 1 - ROT PUT 'p1' STO
p2 3 9 PUT n 9 PUT 'p2' STO
dn DUP
p3 4 ROT PUT n ROT PUT 'p3' STO
END
d1 1 ==
d2 3 < AND d2 0 ≠ AND
d3 3 == AND
dn 3 - 10 MOD AND THEN
"B6"
d2 DUP
p1 1 1 PUT n 1 PUT 2 ROT PUT n 1 - ROT PUT 'p1' STO
p2 3 2 PUT n 2 PUT 'p2' STO
dn 3 - 10 MOD DUP
p3 4 ROT PUT n ROT PUT 'p3' STO
END
d1 1 ==
d2 3 < AND d2 0 ≠ AND
d3 3 == AND
dn 3 == AND THEN
"B7"
d2 DUP
p1 1 1 PUT n 1 PUT 2 ROT PUT n 1 - ROT PUT 'p1' STO
p2 3 1 PUT n 1 PUT 'p2' STO
p3 4 1 PUT n 1 PUT 'p3' STO
END
END
p1 CMPLST DUP SIZE SWAP 'p1' STO
@ Special or normal?
2 IDIV2
IF 0 ≠ THEN DROP 0
ELSE
@ Special if first palindrome has an even no. of
@ digits and one of the middle positions in the input
@ number is zero
DUP
d SWAP GET 0 == SWAP d SWAP 1 + GET 0 == OR 1 0 IFTE
END
d REVLIST
p1
p2 CMPLST
p3 CMPLST
»
»
»
PALIN.zip (Size: 13.62 KB / Downloads: 2)