|
I just found this, I'm trying to day 4 in Haskell, but it's taking over ten minutes to do part one and it's only into the 41,000,000s for some reason. {-# LANGUAGE OverloadedStrings #-} import Crypto.Hash.MD5 as MD5 import Data.ByteString.Char8 () import Data.ByteString.Char8 as BS import Debug.Trace pickBy :: (a -> Bool) -> [a] -> a pickBy p (x:xs) | p x = x | otherwise = pickBy p xs pickBy _ [] = undefined main = do let input = "blahblah" let possible = Prelude.map (\n -> (BS.pack $ input ++ show n, n) ) [1..] let (_, n) = pickBy (\(str, n) -> traceShow n $ (BS.take 5 $ MD5.hash str) == "00000") possible print n
|
# ¿ Dec 29, 2015 07:03 |
|
|
# ¿ May 11, 2024 08:43 |
|
So far this has been putting my reading comprehension skills to the test more than my coding skills.
|
# ¿ Dec 29, 2015 21:01 |