Post Reply 
Programming puzzle: Longest list of regular numbers?
04-18-2017, 10:09 PM (This post was last modified: 04-19-2017 03:27 PM by Claudio L..)
Post: #25
RE: Programming puzzle: Longest list of regular numbers?
(04-18-2017 07:22 PM)Han Wrote:  
(04-18-2017 07:13 PM)pier4r Wrote:  Just saw this: http://www.hpmuseum.org/forum/thread-8201.html

Han, how does the Prime performs?

I do have a Ti89, but I did not use it for years and refreshing the Ti basic now is a no go.

Using the TEVAL command, the hardware calculator returns 0.828 seconds for the 1429-th Hamming number.

And it takes the Prime 133.468 seconds to compute the 9733-rd value. I created a CAS equivalent function in order to handle larger numbers, which ran slightly slower (3.167 seconds) than the non-CAS version when computing the 1429-th value.

For the record:

newRPL running Han's program, unmodified. I did copy/paste from the forum, replaced \<< and other characters with the real Unicode ones and saved as a pure .txt file, put it on an SD card, read the file and compiled with STR->.
For the 1429th value (using 1430 as argument on Han's program, as it counts from one):

1429 ==> newRPL: 0.687 seconds
9733 ==> newRPL: 39.87 seconds without GC (doing MEM before running), 85.21 seconds with heavily fragmented memory (second run immediately after).
14999 ==> newRPL: 94.8 seconds, the result is 2305843009213693952 = 2^61
EDIT:
14999 ==> newRPL: 113.57 seconds, result is 1.236950581248E20
17499 ==> newRPL: 159.46 seconds, result is 1.549681956E21 (only 48 kbytes free memory after)
To answer the original challenge, interpolating linearly between the timings at 17500 and 15000 results, newRPL would obtain 15349 results in 120 seconds.
END EDIT

I maxed out my patience before maxing out the memory. I want to clarify this entry is to report Han's algorithm speed, all credit goes to him for the program as I didn't even read the code.


EDIT: MEM reports 131 kbytes free with all 15000 values on the stack. Also worth clarifying that since these numbers are < 2^63, simple 64-bit integers can be used. For larger numbers the variable precision floating point kicks in and should slow down considerably.
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? - Claudio L. - 04-18-2017 10:09 PM



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