This commit is contained in:
2023-12-18 15:21:29 +01:00
parent a8d5a79235
commit 5d826bffff
5 changed files with 154 additions and 0 deletions

21
day18/Part2.hs Normal file
View File

@@ -0,0 +1,21 @@
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 []