Files
advent-of-code-2023/day18/Part1.hs
2023-12-18 15:21:29 +01:00

20 lines
643 B
Haskell

module Part1 where
import Commons
import Data.List.Utils (split)
import GHC.IO.Handle (isEOF)
import Data.Map (fromList)
parseLine :: (Int, Int) -> String -> ((Int, Int), Hole)
parseLine coords line = let (d: n: _) = split " " line
actualD = case d of
"U" -> North
"D" -> South
"R" -> East
"L" -> West
in parseInstruction coords actualD (read n)
parse :: [String] -> Grid
parse lines = parseGrid parseLine lines []