
dons:
mdanish:
Hello,
I've been playing with the INTEST problem on SPOJ which demonstrates the ability to write a program which processes large quantities of input data. http://www.spoj.pl/problems/INTEST/
But when I make a slight modification, the program chews up a ton more memory and takes more time:
import Control.Monad import Data.Maybe import qualified Data.ByteString.Char8 as B
divisibleBy :: Int -> Int -> Bool a `divisibleBy` n = a `rem` n == 0
main :: IO () main = do [n,k] <- (map int . B.split ' ') `fmap` B.getLine :: IO [Int]
let doLine :: Int -> Int -> IO Int doLine r _ = B.getLine >>= return . testDiv r -- 'return' moved here ^^
And just following up with some GC statistics:
Original,
95% cpu 1.668 total
<