Advent of Code day 12

Advent of Code day 12

In today's puzzle Rain Risk we are navigating a storm. The only problem is that the directions are convoluted. We need to just find the end point and get directly there.

Part 1 is pretty straightforward -- just bookkeeping. I just write a routine to parse the directions and keep track of the location.

Part 2 is also not too difficult. In this case many of the directions actually refer to a waypoint that is used to handle the ship navigation. If you think in the reference frame of the ship and handle waypoint movements from there, it's straightforward. The only difficult part is rotating the waypoint around the ship.

Use simultaneous assignment to make sure you don’t overwrite EW with NS

(NSway, EWway) = (-EWway, NSway)

And that's it, nice and easy. A good break after the last two days.