Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 17 lines (15 sloc) 0.502 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import System
import System.Random.Mersenne
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import Data.Bits
import System.TimeIt

main = do
    args <- getArgs
    let i = read $ head args :: Int
    timeIt $ do
        gen <- getStdGen
        vals <- randoms gen
        let m = IntMap.fromList [(x,x) | x <- take i vals] :: IntMap Int
            rvals = take i (drop (shiftR i 1) vals)
        print (sum [fromIntegral . maybe 0 id $ IntMap.lookup x m | x <- rvals] :: Integer)
Something went wrong with that request. Please try again.