Tuesday, August 4, 2009

Project Euler #17, Take Two

So, here's the completed version of the changes I made using the script from my last post.

It works directly with the number string length rather than the strings themselves, and optimizes the inner loop to only scan the list of numbers with known names once for each call to NumberLength.

The resulting script executes in ten seconds on my MBP, making it about 18 times faster than my first attempt.

I think that's about as far as it is reasonable to take this approach to solving the problem. But that's because this approach, when you get right down to it, is a brute force approach. I suspect there is another huge performance increase to be had by being smarter about the problem. But that is for another day...

No comments:

Post a Comment