aboutsummaryrefslogtreecommitdiff
path: root/execs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-12-06 03:45:11 +0000
committerAkshay <[email protected]>2020-12-06 03:45:11 +0000
commitd41dca8b131d580eed2bcdc382bda9a634c57bf9 (patch)
tree1a5acbc74b5ef6fd2fa6cd198c759235e748e45e /execs
parent555da2ae6f658672cfc0d37e437ec356c0c0fa63 (diff)
le point free has arrived
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