adventofcode/2015/day09/problem

68 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

2018-03-15 16:24:23 +00:00
Advent of Code
2016-12-16 22:21:15 +00:00
--- Day 9: All in a Single Night ---
Every year, Santa manages to deliver all of his presents in a single night.
2018-03-15 16:24:23 +00:00
This year, however, he has some new locations to visit; his elves have
provided him the distances between every pair of locations. He can start and
end at any two (different) locations he wants, but he must visit each
location exactly once. What is the shortest distance he can travel to
achieve this?
2016-12-16 22:21:15 +00:00
For example, given the following distances:
London to Dublin = 464
London to Belfast = 518
Dublin to Belfast = 141
The possible routes are therefore:
Dublin -> London -> Belfast = 982
London -> Dublin -> Belfast = 605
London -> Belfast -> Dublin = 659
Dublin -> Belfast -> London = 659
Belfast -> Dublin -> London = 605
Belfast -> London -> Dublin = 982
2018-03-15 16:24:23 +00:00
The shortest of these is London -> Dublin -> Belfast = 605, and so the
answer is 605 in this example.
2016-12-16 22:21:15 +00:00
What is the distance of the shortest route?
Your puzzle answer was 251.
--- Part Two ---
2018-03-15 16:24:23 +00:00
The next year, just to show off, Santa decides to take the route with the
longest distance instead.
2016-12-16 22:21:15 +00:00
2018-03-15 16:24:23 +00:00
He can still start and end at any two (different) locations he wants, and he
still must visit each location exactly once.
2016-12-16 22:21:15 +00:00
2018-03-15 16:24:23 +00:00
For example, given the distances above, the longest route would be 982 via
(for example) Dublin -> London -> Belfast.
2016-12-16 22:21:15 +00:00
What is the distance of the longest route?
Your puzzle answer was 898.
Both parts of this puzzle are complete! They provide two gold stars: **
2018-03-15 16:24:23 +00:00
At this point, you should return to your advent calendar and try another
puzzle.
2016-12-16 22:21:15 +00:00
If you still want to see it, you can get your puzzle input.
References
Visible links
. http://adventofcode.com/
. http://adventofcode.com/about
. http://adventofcode.com/stats
. http://adventofcode.com/leaderboard
. http://adventofcode.com/settings
. http://adventofcode.com/auth/logout
. http://adventofcode.com/
. http://adventofcode.com/day/9/input