Created
November 2, 2016 20:58
-
-
Save AntonFagerberg/52e01c359779413a07e63f1803780185 to your computer and use it in GitHub Desktop.
Advent of code 2015 - 1 - Haskell
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
num :: Char -> Int | |
num '(' = 1 | |
num ')' = -1 | |
main = readFile "input" >>= putStrLn . show . sum . map num | |
f :: (Int, Int) -> Int -> (Int, Int) | |
f (a, b) c = (a + c, b + 1) | |
cellar :: (Int, Int) -> Bool | |
cellar = (/=) (-1) . fst | |
main2 = readFile "input" >>= putStrLn . show . snd . head . dropWhile cellar . scanl f (0, 0) . map num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment