diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2020-12-05 15:34:00 +0100 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2020-12-05 15:34:00 +0100 |
commit | d4d60939353e01ee79d042a6ae1df5ebee904d80 (patch) | |
tree | b4c416c8dddbe2ba0129b822ebf1bc49de0db677 /2020/5.hs | |
parent | 99a1e56c593774805ed62d3811c963bfca5fbf32 (diff) |
Day 5
Diffstat (limited to '2020/5.hs')
-rw-r--r-- | 2020/5.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/2020/5.hs b/2020/5.hs new file mode 100644 index 0000000..51c9bca --- /dev/null +++ b/2020/5.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE LambdaCase #-} +module Main (main) where + +import Data.List (sort) +import Numeric (readInt) + +import Input + + +parse :: String -> Int +parse = fst . head . readInt 2 (`elem` "FBLR") (\case 'F' -> 0 ; 'B' -> 1 ; 'L' -> 0 ; 'R' -> 1 ; _ -> undefined) + +main :: IO () +main = do + input <- map parse <$> getInput 5 + print (maximum input) + print (fst (head (filter ((== 2) . snd) (zipWith (\a b -> (a+1, b-a)) (sort input) (tail (sort input)))))) |