summaryrefslogtreecommitdiff
path: root/2020/5.hs
blob: 51c9bca76d67d855ff69e9f60c85512021f7e092 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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))))))