Post Reply 
HP 50g: Programming Problem: Integer Partition in Palindromic Integers
02-18-2018, 01:50 AM
Post: #22
RE: HP 50g: Programming Problem: Integer Partition in Palindromic Integers
Hello Gerald H, in my previous program I wanted to see if I can have an IFTE structure inside another one and it did work. The problem with comparing the two strings got me thinking that it is not necessary to compare the hole number but just last half of it. Now the program is 195 bytes and the check-sum is # 4007h. Thanks for the remarks that help improve the program.
Code:
«
 WHILE DUP →STR DUPDUP SIZE DUP 1 >
 REPEAT
  2 / SWAP 1 PICK3 SUB DUP OBJ→ 1 - →STR
  IF DUP2 SIZE SWAP SIZE ==
  THEN
   4 ROLL 4 PICK 1 + OVER SIZE SUB OBJ→
   PICK3 1 6 PICK FLOOR SUB OBJ→ > UNROT IFTE
   DUP 1 4 ROLL FLOOR SUB + OBJ→ SWAP OVER -
  ELSE
   4 DROPN 1 - 1
  END
 END 3 DROPN
»
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 50g: Programming Problem: Integer Partition in Palindromic Integers - Juan14 - 02-18-2018 01:50 AM



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