adventofcode/day01/problem

62 lines
2.8 KiB
Plaintext
Raw Normal View History

Advent of Code
2016-12-01 13:46:32 +00:00
--- Day 1: No Time for a Taxicab ---
2016-12-01 13:46:32 +00:00
Santa's sleigh uses a very high-precision clock to guide its movements, and the clock's oscillator is regulated by stars. Unfortunately, the stars have been stolen... by the Easter Bunny. To save Christmas, Santa needs you to
retrieve all fifty stars by December 25th.
2016-12-01 13:46:32 +00:00
Collect stars by solving puzzles. Two puzzles will be made available on each day in the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
2016-12-01 13:46:32 +00:00
You're airdropped near Easter Bunny Headquarters in a city somewhere. "Near", unfortunately, is as close as you can get - the instructions on the Easter Bunny Recruiting Document the Elves intercepted start here, and nobody had time
to work them out further.
2016-12-01 13:46:32 +00:00
The Document indicates that you should start at the given coordinates (where you just landed) and face North. Then, follow the provided sequence: either turn left (L) or right (R) 90 degrees, then walk forward the given number of
blocks, ending at a new intersection.
2016-12-01 13:46:32 +00:00
There's no time to follow such ridiculous instructions on foot, though, so you take a moment and work out the destination. Given that you can only walk on the street grid of the city, how far is the shortest path to the destination?
2016-12-01 13:46:32 +00:00
For example:
2016-12-01 13:46:32 +00:00
 Following R2, L3 leaves you 2 blocks East and 3 blocks North, or 5 blocks away.
 R2, R2, R2 leaves you 2 blocks due South of your starting position, which is 2 blocks away.
 R5, L5, R5, R3 leaves you 12 blocks away.
2016-12-01 13:46:32 +00:00
How many blocks away is Easter Bunny HQ?
2016-12-01 13:46:32 +00:00
Your puzzle answer was 243.
2016-12-01 13:46:32 +00:00
--- Part Two ---
2016-12-01 13:46:32 +00:00
Then, you notice the instructions continue on the back of the Recruiting Document. Easter Bunny HQ is actually at the first location you visit twice.
2016-12-01 13:46:32 +00:00
For example, if your instructions are R8, R4, R4, R8, the first location you visit twice is 4 blocks away, due East.
2016-12-01 13:46:32 +00:00
How many blocks away is the first location you visit twice?
2016-12-01 15:26:41 +00:00
Your puzzle answer was 142.
2016-12-01 15:26:41 +00:00
Both parts of this puzzle are complete! They provide two gold stars: **
2016-12-01 15:26:41 +00:00
At this point, you should return to your advent calendar and try another puzzle.
2016-12-01 15:26:41 +00:00
If you still want to see it, you can get your puzzle input.
2016-12-01 15:26:41 +00:00
References
2016-12-01 15:26:41 +00:00
Visible links
. http://adventofcode.com/
. http://adventofcode.com/2016/about
. http://adventofcode.com/2016/support
. http://adventofcode.com/2016/events
. http://adventofcode.com/2016/settings
. http://adventofcode.com/2016/auth/logout
. http://adventofcode.com/2016
. http://adventofcode.com/2016
. http://adventofcode.com/2016/leaderboard
. http://adventofcode.com/2016/stats
. http://adventofcode.com/2016/sponsors
. http://adventofcode.com/2016/sponsors
. https://en.wikipedia.org/wiki/Taxicab_geometry
. http://adventofcode.com/2016
. http://adventofcode.com/2016/day/1/input