X-Git-Url: https://git.njae.me.uk/?p=advent-of-code-20.git;a=blobdiff_plain;f=advent12%2Fsrc%2Fadvent12.hs;h=4d0e39d5eebe71b7d7eda22081151df60b8a5173;hp=e52e2794653671d5177e7a7bc1fda04ebef969d0;hb=98771bc642f4f5d28b8374944bd9398631d126fd;hpb=d86a864714157b49f6104d14add219b535c61ad6 diff --git a/advent12/src/advent12.hs b/advent12/src/advent12.hs index e52e279..4d0e39d 100644 --- a/advent12/src/advent12.hs +++ b/advent12/src/advent12.hs @@ -67,6 +67,7 @@ act Ship{..} (R a) = Ship { direction = d, ..} where d = (iterate succW directio act Ship{..} (F d) = Ship { position = dDelta d direction position, ..} +actW :: Ship -> Action Int -> Ship actW Ship{..} (N d) = Ship { waypoint = dDelta d North waypoint, ..} actW Ship{..} (S d) = Ship { waypoint = dDelta d South waypoint, ..} actW Ship{..} (W d) = Ship { waypoint = dDelta d West waypoint, ..} @@ -76,7 +77,7 @@ actW Ship{..} (R a) = Ship { waypoint = d, ..} where d = (iterate rotR waypoint) actW Ship{..} (F d) = Ship { position = p', ..} where (x, y) = position (dx, dy) = waypoint - p' = (x + (d* dx), y + (d * dy)) + p' = (x + (d * dx), y + (d * dy)) rotL (x, y) = (-y, x) rotR (x, y) = (y, -x)