
On Sun, 2009-08-30 at 18:50 +0400, Eugene Kirpichov wrote:
Thanks :) I wonder why SPOJ didn't accept the same thing from me.
I think that in order to obtain even higher performance we need to resort to low-level IO: raw reading into a byte buffer and parsing the very buffer to avoid memcpy'ing. Or, better, to use Oleg's iteratees with a file handle enumerator. I'll probably give it a try when I have time, but there's a 70% chance that I won't, so someone please try it, it should work :)
I just discovered that the SPOJ question regarding the problem http://www.spoj.pl/problems/INTEST/ had already been asked about 2 years ago. http://groups.google.com/group/fa.haskell/browse_thread/thread/4133fa71ce97e... Donald Stewart gave a solution - long, complex and highly optimised using knowledge of Data.ByteString internals. But fast - 2 or 3 times as fast as your method. Steve