[Haskell-beginners] Re: Help with slow algorithm

Heinrich Apfelmus apfelmus at quantentunnel.de
Sun May 16 10:33:25 EDT 2010


Daniel Fischer wrote:
> Heinrich Apfelmus wrote:
>> Diego Echeverri wrote:
>>> I believe that the bottleneck is in the addOne function (Specially in
>>> the case where you have a bunch of nines). I have rewritten it to use
>>> STArray but isn't fast enough.
>>> doing: addOne $ B.replicate 500000 'a' takes too much time!
>>
>> Are you sure that you are using a fast algorithm? For instance, starting
>> with k and counting up until you reach a palindrome is definitely not a
>> good idea; you need to do something cleverer.
>>
> 
> Deceived by a name :)
> 
> He did something cleverer. His algorithm is good, just the implementation 
> leaves much room for improvement.

Oops, my bad. :-$


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



More information about the Beginners mailing list