Post Reply 
HP 50g: Programming Problem: Integer Partition in Palindromic Integers
02-08-2018, 12:17 PM
Post: #11
RE: HP 50g: Programming Problem: Integer Partition in Palindromic Integers
Here a smaller & faster version of the programme, produces the same elements of partitions:

Size: 469.5 Bytes

CkSum: # 44E7h

Code:
« 0 SWAP
  WHILE SWAP 1 + SWAP DUPDUP →STR DUPDUP SREV SAME
    IF
    THEN DROP
    ELSE DUP SIZE 2. IDIV2 DUP 4 ROLLD + 1. SWAP SUB DUP SREV ROT 1 SAME
      IF
      THEN TAIL
      END + OBJ→ DUP UNROT <
      IF
      THEN →STR DUP SIZE 2. IDIV2 DUP UNROT
        IF
        THEN 1. + SUB DUP TAIL SWAP HEAD OBJ→ 1 + SWAP +
        ELSE SUB 1 SWAP +
        END OBJ→ 1 - DUP 2. <
        IF
        THEN 0
        ELSE 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
      END
    END DUP2 SAME NOT
  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-08-2018 12:17 PM



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