Post Reply 
HP 50g: Programming Problem: Integer Partition in Palindromic Integers
02-09-2018, 05:43 AM
Post: #12
RE: HP 50g: Programming Problem: Integer Partition in Palindromic Integers
A further rationalisation of the programme, shorter & faster:

Size: 431. Bytes

CkSum: # 8EABh

Code:
« 0 SWAP
  WHILE SWAP 1 + SWAP DUPDUP →STR DUPDUP SREV SAME
    IF
    THEN DROP 0.
    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 →STR SWAP DUP FP DUP UNROT
        IF
        THEN SUB DUP TAIL SWAP HEAD OBJ→ 1 +
        ELSE SUB 1
        END SWAP + OBJ→ 1 - DUP →STR DUP HEAD "1" SAME OVER 2. 2. SUB "0" SAME NOT AND
        IF
        THEN TAIL DUP SREV
        ELSE DUP TAIL SWAP HEAD OBJ→ 1 - DUP NOT
          IF
          THEN DROP TAIL 9
          END SWAP + DUP SREV TAIL
        END + OBJ→
      END NIP DUP2 -
    END
  REPEAT DUP 4. ROLLD -
  END DROP SWAP DUPDUP 2. + ROLLD →LIST SWAP →TAG
»
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 - Gerald H - 02-09-2018 05:43 AM



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