Day 18
This commit is contained in:
21
day18/Part2.hs
Normal file
21
day18/Part2.hs
Normal 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 []
|
||||
Reference in New Issue
Block a user