Skip to content

Instantly share code, notes, and snippets.

@ddrone
Created December 6, 2014 16:11
Show Gist options
  • Save ddrone/44e2b565c4b307a74a82 to your computer and use it in GitHub Desktop.
Save ddrone/44e2b565c4b307a74a82 to your computer and use it in GitHub Desktop.
ProjectEuler score calculator
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