4 import qualified Data.Set as S
8 do text <- readFile "data/advent05.txt"
9 let passes = lines text
13 part1 = maximum . map convert
15 part2 passes = S.elemAt 0 $ expecteds `S.difference` knowns
16 where ns = map convert passes
19 knowns = S.fromList ns
20 expecteds = S.fromList [lowest..highest]
22 directionToInt :: Char -> Int
23 directionToInt dir = if dir `elem` "BR" then 1 else 0
25 convert :: String -> Int
26 convert = fst . head . readInt 2 (`elem` "FBLR") directionToInt