Post Reply 
Tripartite Palindromic Partition of Integer (HP 50g) Challenge
02-21-2023, 05:46 PM
Post: #20
RE: Tripartite Palindromic Partition of Integer (HP 50g) Challenge
(02-19-2023 09:49 PM)peruna Wrote:  Some programs involving palindromic numbers. (Note: ± is char 177 from the CHARS menu.)

'P?' # 2979h 22. Test if number is palindromic
Code:
«   →STR DUP ± ==
»

1331 P? → 1

1332 P? → 0

'±' # 7F80h 48. Reverse string or list
Code:
«   DUP SIZE { DUP HEAD SWAP TAIL ± SWAP + } IFT
»

"1234" ± → "4321"

Interesting programs, and very nice programming style IMHO. If you use the ListExt Library, your program '±' can be replaced by REV, and P? can be replaced by
Code:
«   DUP REV SAME
»
The command REV will reverse a string, a list or an integer and is many times faster than any User RPL equivalent.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Tripartite Palindromic Partition of Integer (HP 50g) Challenge - John Keith - 02-21-2023 05:46 PM



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