diff options
author | Akshay <[email protected]> | 2020-12-06 03:45:11 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-12-06 03:45:11 +0000 |
commit | d41dca8b131d580eed2bcdc382bda9a634c57bf9 (patch) | |
tree | 1a5acbc74b5ef6fd2fa6cd198c759235e748e45e /execs | |
parent | 555da2ae6f658672cfc0d37e437ec356c0c0fa63 (diff) |
le point free has arrived
Diffstat (limited to 'execs')
-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 |