-- import Debug.Trace
+
import AoC
import Prelude hiding (Left, Right)
import qualified Data.Map.Strict as M
where isRow = r < length rows
isCol = c < (length $ rows !! r)
-mkInstructions :: String -> [PathElement]
+mkInstructions, mkWalk, mkTurn :: String -> [PathElement]
mkInstructions [] = []
-mkInstructions text@(t:ts)
+mkInstructions text@(t:_)
| isDigit t = mkWalk text
| otherwise = mkTurn text
+
mkWalk text = (Forward $ read digits) : (mkInstructions remainder)
where (digits, remainder) = span (isDigit) text
+
+mkTurn [] = []
mkTurn (t:ts)
| t == 'R' = Clockwise : (mkInstructions ts)
| t == 'L' = Anticlockwise : (mkInstructions ts)