22 lines
786 B
Haskell
22 lines
786 B
Haskell
module Part2 where
|
|
|
|
import Commons
|
|
import Numeric (readHex)
|
|
import Data.List.Utils (split)
|
|
|
|
|
|
parseColor :: String -> (Int, Direction)
|
|
parseColor raw = (fst $ head $ readHex $ init raw, case last raw of
|
|
'0' -> East
|
|
'1' -> South
|
|
'2' -> West
|
|
'3' -> North)
|
|
|
|
parseLine :: (Int, Int) -> String -> ((Int, Int), Hole)
|
|
parseLine coords line = let (_: _: ('(': '#': c): _) = split " " line
|
|
(n, d) = parseColor $ init c
|
|
in parseInstruction coords d n
|
|
|
|
parse :: [String] -> Grid
|
|
parse lines = parseGrid parseLine lines []
|