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
 C.Ret Member Posts: 258 Joined: Dec 2013
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.
 « Next Oldest | Next Newest »

 Messages In This Thread Programming puzzle: Longest list of regular numbers? - pier4r - 04-16-2017, 03:02 PM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-16-2017, 07:57 PM RE: Programming puzzle: Longest list of regular numbers? - e_emil - 04-16-2017, 08:22 PM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-16-2017, 09:00 PM RE: Programming puzzle: Longest list of regular numbers? - e_emil - 04-16-2017, 09:05 PM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-17-2017, 03:30 PM RE: Programming puzzle: Longest list of regular numbers? - Han - 04-17-2017, 04:02 PM RE: Programming puzzle: Longest list of regular numbers? - Dave Britten - 04-17-2017, 01:42 AM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-17-2017, 06:28 AM RE: Programming puzzle: Longest list of regular numbers? - e_emil - 04-17-2017, 10:58 AM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-17-2017, 11:24 AM RE: Programming puzzle: Longest list of regular numbers? - e_emil - 04-17-2017, 12:28 PM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-17-2017, 02:10 PM RE: Programming puzzle: Longest list of regular numbers? - Dave Britten - 04-17-2017, 11:32 AM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-17-2017, 02:05 PM RE: Programming puzzle: Longest list of regular numbers? - Han - 04-17-2017, 02:20 PM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-17-2017, 04:05 PM RE: Programming puzzle: Longest list of regular numbers? - e_emil - 04-17-2017, 05:52 PM RE: Programming puzzle: Longest list of regular numbers? - Han - 04-17-2017, 06:50 PM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-17-2017, 07:06 PM RE: Programming puzzle: Longest list of regular numbers? - Han - 04-17-2017, 07:52 PM RE: Programming puzzle: Longest list of regular numbers? - e_emil - 04-17-2017, 07:53 PM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-18-2017, 07:13 PM RE: Programming puzzle: Longest list of regular numbers? - Han - 04-18-2017, 07:22 PM RE: Programming puzzle: Longest list of regular numbers? - Claudio L. - 04-18-2017, 10:09 PM RE: Programming puzzle: Longest list of regular numbers? - Claudio L. - 04-18-2017, 10:36 PM RE: Programming puzzle: Longest list of regular numbers? - Claudio L. - 04-19-2017, 03:09 PM RE: Programming puzzle: Longest list of regular numbers? - C.Ret - 01-13-2021, 06:39 PM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-18-2017, 11:10 PM RE: Programming puzzle: Longest list of regular numbers? - e_emil - 04-19-2017, 10:43 AM RE: Programming puzzle: Longest list of regular numbers? - pier4r - 04-19-2017, 04:06 PM RE: Programming puzzle: Longest list of regular numbers? - John Keith - 01-16-2021, 09:33 PM RE: Programming puzzle: Longest list of regular numbers? - C.Ret - 01-17-2021, 09:02 PM RE: Programming puzzle: Longest list of regular numbers? - John Keith - 01-18-2021, 05:44 PM RE: Programming puzzle: Longest list of regular numbers? - C.Ret - 01-19-2021 04:58 PM

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