Post Reply 
Programming puzzle: Longest list of regular numbers?
01-19-2021, 04:58 PM (This post was last modified: 01-19-2021 05:10 PM by C.Ret.)
Post: #35
RE: Programming puzzle: Longest list of regular numbers?
(01-18-2021 05:44 PM)John Keith Wrote:  The HP-48G and later have a built-in SORT command but it is notoriously slow. Fortunately there is LSORT which is orders of magnitude faster.

If you plan to use an LSORT instruction, you may can use a code like the one I made to test my algorithm with a home-made HP-28S's LSORT program:

Code:
« → r « HRAZ "Enumaring..." 1 DISP
        DO
          1 X + 'X' STO
          0  X LA * FOR y
            X LB * y LC * - IP → z
              « IF 'E' y 1 +  GET z < THEN 
                                       'E' y 1 + z PUT
                                         N 1 + 'N' STO
                  H y L3 * z L5 * + X L2 * - + 'H' STO
                END »
          NEXT
          T N + DUP 'T' STO
        UNTIL T r >= END "Sorting..." 1 DISP
        2 X ^ H   LSORT   N r + T - GET EXP * CEIL
        1240 .2 BEEP CLMF » »


No hash-table here, all the value are collected in the 'H' list, then 'H' is sort and the expected result extract from the sorted list directly.
This is the exact algorithm I use on my HP Prime which have a powerfull parametric SORT instruction.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzle: Longest list of regular numbers? - C.Ret - 01-19-2021 04:58 PM



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