Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.
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

Adbot
ADBOT LOVES YOU

Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.
So far this has been putting my reading comprehension skills to the test more than my coding skills.

  • Locked thread