Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

17 lines (15 sloc) 0.502 kB
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)
Jump to Line
Something went wrong with that request. Please try again.