Skip to content

Instantly share code, notes, and snippets.

@scan
Forked from anonymous/epicWin.hs
Created April 3, 2012 09:15
Show Gist options
  • Save scan/2290605 to your computer and use it in GitHub Desktop.
Save scan/2290605 to your computer and use it in GitHub Desktop.
module Main where
import Data.List
main = interact epicWin
epicWin :: String -> String
epicWin s = let x :: Integer
x = read (head (lines s))
in (show $ div (getTotal (tail (lines s))) x) ++ "\n"
getTotal :: [String] -> Integer
getTotal ls = getTotal' ls 0
where
getTotal' [] t = t
getTotal' (l:lss) t = getTotal' lss $ t + (getTime $ map read (words l))
getTime :: [Integer] -> Integer
getTime is = let x = zipWith (-) (drop 2 is) (take 2 is)
y = ((head x) * 60) + (head (tail x))
in if y < 0 then 0 else y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment