2019 day 6: parts 1 and 2, before cleaning (lots of printf ;-)
This commit is contained in:
@@ -76,3 +76,72 @@ The total number of direct and indirect orbits in this example is =42=.
|
||||
|
||||
/What is the total number of direct and indirect orbits/ in your map
|
||||
data?
|
||||
|
||||
Your puzzle answer was =453028=.
|
||||
|
||||
** --- Part Two ---
|
||||
Now, you just need to figure out how many /orbital transfers/ you
|
||||
(=YOU=) need to take to get to Santa (=SAN=).
|
||||
|
||||
You start at the object =YOU= are orbiting; your destination is the
|
||||
object =SAN= is orbiting. An orbital transfer lets you move from any
|
||||
object to an object orbiting or orbited by that object.
|
||||
|
||||
For example, suppose you have the following map:
|
||||
|
||||
#+BEGIN_EXAMPLE
|
||||
COM)B
|
||||
B)C
|
||||
C)D
|
||||
D)E
|
||||
E)F
|
||||
B)G
|
||||
G)H
|
||||
D)I
|
||||
E)J
|
||||
J)K
|
||||
K)L
|
||||
K)YOU
|
||||
I)SAN
|
||||
#+END_EXAMPLE
|
||||
|
||||
Visually, the above map of orbits looks like this:
|
||||
|
||||
#+BEGIN_EXAMPLE
|
||||
YOU
|
||||
/
|
||||
G - H J - K - L
|
||||
/ /
|
||||
COM - B - C - D - E - F
|
||||
\
|
||||
I - SAN
|
||||
#+END_EXAMPLE
|
||||
|
||||
In this example, =YOU= are in orbit around =K=, and =SAN= is in orbit
|
||||
around =I=. To move from =K= to =I=, a minimum of =4= orbital transfers
|
||||
are required:
|
||||
|
||||
- =K= to =J=
|
||||
- =J= to =E=
|
||||
- =E= to =D=
|
||||
- =D= to =I=
|
||||
|
||||
Afterward, the map of orbits looks like this:
|
||||
|
||||
#+BEGIN_EXAMPLE
|
||||
G - H J - K - L
|
||||
/ /
|
||||
COM - B - C - D - E - F
|
||||
\
|
||||
I - SAN
|
||||
\
|
||||
YOU
|
||||
#+END_EXAMPLE
|
||||
|
||||
/What is the minimum number of orbital transfers required/ to move from
|
||||
the object =YOU= are orbiting to the object =SAN= is orbiting? (Between
|
||||
the objects they are orbiting - /not/ between =YOU= and =SAN=.)
|
||||
|
||||
Your puzzle answer was =562=.
|
||||
|
||||
Both parts of this puzzle are complete! They provide two gold stars: **
|
||||
|
Reference in New Issue
Block a user