Created
August 16, 2010 08:10
-
-
Save anonymous/526610 to your computer and use it in GitHub Desktop.
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
import Data.List | |
main = interact $ unlines . map showSolution . zip [1..] . map solve . parseProblems | |
parseProblems = parse . map (map read . words) . tail . lines | |
where parse [] = [] | |
parse ([n]:xs) = map (\ [x,y] -> (x,y)) (take n xs) : parse (drop n xs) | |
showSolution (n, s) = "Case #" ++ show n ++ ": " ++ show s | |
solve xs = sum [ fromEnum $ signum (l1-l2) /= signum (r1-r2) | (l1,r1):ys <- tails xs, (l2,r2) <- ys ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment