Post Reply 
HP 50g: Programming Problem: Integer Partition in Palindromic Integers
02-13-2018, 06:31 PM
Post: #19
RE: HP 50g: Programming Problem: Integer Partition in Palindromic Integers
(02-10-2018 06:16 AM)Gerald H Wrote:  A much reduced version of my programme & faster:

Size: 300.5 Bytes

CkSum: # 933Ch

Code:
« 0 SWAP
  WHILE SWAP 1 + SWAP DUPDUP →STR DUPDUP SREV SAME
    IF
    THEN DROP 0.
    ELSE DUP SREV OBJ→ 1 ==
      IF
      THEN DROP 1 - DUP
      ELSE 1. OVER SIZE 2. / DUP 5. ROLLD DUP FP 4. ROLLD SUB DUP SREV ROT
        IF
        THEN TAIL
        END + OBJ→ DUP UNROT <
        IF
        THEN DROP OVER →STR 1. PICK3 SUB OBJ→ 1 - →STR DUP SREV PICK3 FP
          IF
          THEN TAIL
          END + OBJ→
        END
      END NIP DUP2 -
    END
  REPEAT DUP 4. ROLLD -
  END DROP SWAP DUPDUP 2. + ROLLD →LIST SWAP →TAG
»

The version in post #12 is actually faster on my physical calculator and emulator. A neat program though, and surprisingly fast- less than 8 seconds for 32000-digit numbers on the physical calc!

John
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 - John Keith - 02-13-2018 06:31 PM



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