Log in to get your input and submit your answers.
Day 12: Rain Risk
After the keynote in the amphitheater, you need to head over to the Bocal to collect some hardware. But with corridors under construction, skybridges, and convoluted detours between 42's buildings, navigation is quite a puzzle.
The Bocal's campus navigation app transmits a sequence of instructions (your puzzle input). Each line consists of an action letter and an integer value:
Nmeans to move North by the given value.Smeans to move South by the given value.Emeans to move East by the given value.Wmeans to move West by the given value.Lmeans to turn left the given number of degrees.Rmeans to turn right the given number of degrees.Fmeans to move forward in the direction you are currently facing.
Part 1
You start at coordinates (0, 0) facing East.
Actions N, S, E, and W move you without changing the direction you are facing. Only actions L and R rotate your heading.
Example
Consider this sequence of navigation instructions:
F10
N3
F7
R90
F11Here is how they execute step by step:
F10: moves 10 units East -> position(10, 0), still facing East.N3: moves 3 units North -> position(10, 3), still facing East.F7: moves 7 units East -> position(17, 3), still facing East.R90: turns 90° right -> now facing South (position unchanged).F11: moves 11 units South -> final position(17, -8).
The Manhattan distance (|x| + |y|) from the starting location is: |17| + |-8| = 25.
Execute the instructions from your own input. What is the Manhattan distance between that location and your starting position?