[Haskell-cafe] Slow IO or bad code?
j.vimal at gmail.com
Thu Aug 9 15:13:30 EDT 2007
On 8/9/07, Marc Weber <marco-oweber at gmx.de> wrote:
> > I wrote a code, but seems to give "Time limit exceeded"!
> Your code writes
> 15 to stdout which is correct (with the example given on the page)..
> You have to explain what you mean by >>seems to give "Time limit exceeded"<<
> > loop t function
> Does already exist.
> sequence $ replicate 10 function
> is a much shorter way :-)
> oor perhaps mapM_ [ function | i <- [1..10] ] )
> prod, to_int:
> You can both implement using higher order functions
> prod = sum . zipWith (*)
> to_int = map read
Thanks :) Yes, I see no reason why the code should be rejected by the
judge (Time limit exceeded) just because I had defined all the
functions. I had done this on many other occasions, and they all had
I think that it has a lot to do with the (read) function and how it is
implemented. So parsing takes quite a bit of time, and eventually most
of the time gets used up in processing input.
But the new functions are wonderful :-) I had a hunch that these
functions should have been defined, but I learnt a lot in the process
of writing those functions again!
More information about the Haskell-Cafe