97 lines
2.5 KiB
Markdown
97 lines
2.5 KiB
Markdown
# No Time For Directions!
|
|
|
|
**Hermes** is the Greek god of, amongst others, travel, trade, and athletes.
|
|
Hermes has placed his hope in you.
|
|
|
|
You're dropped to a random location near Mount Cyllene in Arcadia, widely considered the birthplace
|
|
of Hermes. After years of training, **You** are now set out on a quest. You must steal a key from
|
|
**Hecate**, hidden near Mount Cyllene.
|
|
|
|
Unfortunately, "near", is as close as you know where you are. The instructions on the parchment
|
|
Hermes gave begin from here, however, he never had the time to tell you how to follow them, or where
|
|
they lead to.
|
|
|
|
The document has different markings that appear to tell you which direction to travel in. They
|
|
indicate a direction, (`N`, `S`, `E` or `W`), and the number of steps you must take to find the
|
|
hiding location.
|
|
|
|
The problem is, that there's over a 100 different directions, and there's no time following these
|
|
directions one by one. It will take far too long! You take a moment and work out the final
|
|
destination, so you can get more quickly. Given that you can only walk in the cardinal directions,
|
|
what is the shortest path to the destination?
|
|
|
|
### Example
|
|
|
|
- Given the following input
|
|
|
|
|
|
```
|
|
N5
|
|
E2
|
|
S9
|
|
W3
|
|
```
|
|
|
|
Instructs you to to travel `5` steps North, `2` steps East, `9` steps South,
|
|
and `3` steps West. Simplifying it, means `4` steps South, and `1` step West,
|
|
or `5` steps away.
|
|
|
|
- Given the following input
|
|
|
|
```
|
|
N6
|
|
E5
|
|
N5
|
|
W3
|
|
N4
|
|
S9
|
|
E4
|
|
S1
|
|
W6
|
|
E3
|
|
```
|
|
|
|
Leaves you `5` steps North, and `3` steps East, or `8` steps away.
|
|
|
|
Each line will have **at least 2** characters of input, the first being the direction, and
|
|
the second being the number of steps. The number of steps on each line will
|
|
always be between 1 and 9, inclusive, steps.
|
|
|
|
**How many steps away** is the key?
|
|
|
|
{{ if .Part1.Completed -}}
|
|
|
|
**Congratulations! You got Part 1 correct. Your answer was `{{ .Part1.Solution }}`.**
|
|
|
|
## Part 2
|
|
|
|
After some more inspection of the instructions, you decipher the final clue. The final location of
|
|
the steps lead you to a different location. However, the first location you visit **twice** is the
|
|
location where the key is hidden.
|
|
|
|
### Example
|
|
|
|
Given the following input:
|
|
|
|
```
|
|
S7
|
|
W9
|
|
E4
|
|
N4
|
|
S3
|
|
E5
|
|
S1
|
|
```
|
|
|
|
The first location visit twice is `7` blocks away South.
|
|
|
|
With these new instructions, to find the key, **how many steps away is the first location you visit
|
|
twice?**
|
|
|
|
{{ if .Part2.Completed -}}
|
|
|
|
**Congratulations! You have completed both parts! The answer was `{{ .Part2.Solution }}`.**
|
|
|
|
{{- end }}
|
|
{{- end }}
|