Created
December 6, 2014 16:11
-
-
Save ddrone/44e2b565c4b307a74a82 to your computer and use it in GitHub Desktop.
ProjectEuler score calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Monad | |
import Data.Functor ((<$>)) | |
import Text.HTML.TagSoup | |
extractData tags = | |
case dropWhile (~/= "<td class=problem_solved>") tags of | |
[] -> [] | |
ls@(hd : tl) -> (take 8 ls : extractData tl) | |
extractCounts :: [Tag String] -> (Int, Int) | |
extractCounts tags = | |
let [task_no, task_solved] = [ c | TagText c <- tags ] | |
in (read task_no, (read . (!! 4) . words) task_solved) | |
main = | |
do stats <- (map extractCounts . extractData . parseTags) <$> readFile "progress.html" | |
let counts = map snd stats | |
score = sum $ map ((200 /) . fromIntegral) counts | |
print stats | |
print score |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment