HP 50g: Programming Problem: Integer Partition in Palindromic Integers
|
02-10-2018, 09:00 PM
Post: #17
|
|||
|
|||
RE: HP 50g: Programming Problem: Integer Partition in Palindromic Integers
Very nice programme again, powers of ten now partitioned with 2 elements rather than 3.
The IFTE construction reduces the size of the programme but makes it slower than using IF THEN ELSE END. The programme still fails for larger, eg 6000 digit, numbers. I think the problem is in the part I have put in bold red below - I believe the comparison should be between the two numbers contained in the character strings rather than the character strings themselves. « WHILE DUP 9 > REPEAT DUP →STR SIZE OVER 1 - →STR SIZE == « DUP →STR DUPDUP SIZE 2 / SWAP 1 PICK3 SUB DUPDUP 1 5 PICK FLOOR SUB SREV + 4 ROLL OVER < { DROP OBJ→ 1 - →STR DUP 1 4 ROLL FLOOR SUB SREV + } { NIP NIP } IFTE OBJ→ SWAP OVER - » { 1 - 1 } IFTE END » |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)