diff options
-rw-r--r-- | execs/Day05.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/execs/Day05.hs b/execs/Day05.hs index 27397f7..a47c024 100644 --- a/execs/Day05.hs +++ b/execs/Day05.hs | |||
@@ -1,6 +1,7 @@ | |||
1 | module Main where | 1 | module Main where |
2 | 2 | ||
3 | import Data.Char (digitToInt) | 3 | import Data.Char (digitToInt) |
4 | import Data.List (sort) | ||
4 | import Utils (binaryToInt) | 5 | import Utils (binaryToInt) |
5 | 6 | ||
6 | doValidate = binaryToInt . map readBin | 7 | doValidate = binaryToInt . map readBin |
@@ -10,7 +11,7 @@ readBin s | s `elem` "FL" = '0' | |||
10 | main :: IO () | 11 | main :: IO () |
11 | main = do | 12 | main = do |
12 | n <- lines <$> readFile "input/05" | 13 | n <- lines <$> readFile "input/05" |
13 | let valids = map doValidate n | 14 | let valids = sort $ map doValidate n |
14 | ans1 = maximum valids | 15 | ans1 = maximum valids |
15 | print ans1 | 16 | print ans1 |
16 | print $ sum [minimum valids .. ans1] - sum valids | 17 | print $ (+1) . fst . head . dropWhile ((==1) . uncurry (flip (-))) . (zip <*> tail) $ valids |