Little explorations with HP calculators (no Prime)
|
12-28-2018, 02:00 PM
Post: #328
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(12-28-2018 09:06 AM)ijabbott Wrote: I'm not that fluent in Python, but surely the O(n^2) versions of match_count above could be replaced with an O(n) version to speed it up a bit? Yes, his version nicely speeds up the match_count process. I didn't take the time to absorb it when I first looked at it, but my "aha!" moment occurred when I was thinking about implementing a SysRPL version of this test. As I was working through the possibilities in my head, I thought about rearranging the list being tested to make it easier to keep track of the running totals, and it suddenly hit me: "ahh, that's what Albert was doing with zip!" The light bulb flashed in my head, and I felt a little less confused for a moment. python's cProfile airs the real "dirty laundry" of this process, though, and it's something that none of our code snippets have addressed: random.shuffle(). If I'm reading the the profile report correctly, it appears that about 92% of the time taken by the fastest version (so far) was spent performing shuffles: Code: 4849009 function calls in 3.345 seconds The code that caused that result was a combination of Thomas Klemm's main() with Albert Chan's match_count(): Code: import random |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)