aboutsummaryrefslogtreecommitdiff
path: root/execs
diff options
context:
space:
mode:
Diffstat (limited to 'execs')
-rw-r--r--execs/Day05.hs5
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 @@
1module Main where 1module Main where
2 2
3import Data.Char (digitToInt) 3import Data.Char (digitToInt)
4import Data.List (sort)
4import Utils (binaryToInt) 5import Utils (binaryToInt)
5 6
6doValidate = binaryToInt . map readBin 7doValidate = binaryToInt . map readBin
@@ -10,7 +11,7 @@ readBin s | s `elem` "FL" = '0'
10main :: IO () 11main :: IO ()
11main = do 12main = 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