2018-03-15 16:24:23 +00:00
|
|
|
|
Advent of Code
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
--- Day 19: Medicine for Rudolph ---
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Rudolph the Red-Nosed Reindeer is sick! His nose isn't shining very
|
|
|
|
|
brightly, and he needs medicine.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Red-Nosed Reindeer biology isn't similar to regular reindeer biology;
|
|
|
|
|
Rudolph is going to need custom-made medicine. Unfortunately, Red-Nosed
|
|
|
|
|
Reindeer chemistry isn't similar to regular reindeer chemistry, either.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
The North Pole is equipped with a Red-Nosed Reindeer nuclear fusion/fission
|
|
|
|
|
plant, capable of constructing any Red-Nosed Reindeer molecule you need. It
|
|
|
|
|
works by starting with some input molecule and then doing a series of
|
|
|
|
|
replacements, one per step, until it has the right molecule.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
However, the machine has to be calibrated before it can be used. Calibration
|
|
|
|
|
involves determining the number of molecules that can be generated in one
|
|
|
|
|
step from a given starting point.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
For example, imagine a simpler machine that supports only the following
|
|
|
|
|
replacements:
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
H => HO
|
|
|
|
|
H => OH
|
|
|
|
|
O => HH
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Given the replacements above and starting with HOH, the following molecules
|
|
|
|
|
could be generated:
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
• HOOH (via H => HO on the first H).
|
|
|
|
|
• HOHO (via H => HO on the second H).
|
|
|
|
|
• OHOH (via H => OH on the first H).
|
|
|
|
|
• HOOH (via H => OH on the second H).
|
|
|
|
|
• HHHH (via O => HH).
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
So, in the example above, there are 4 distinct molecules (not five, because
|
|
|
|
|
HOOH appears twice) after one replacement from HOH. Santa's favorite
|
|
|
|
|
molecule, HOHOHO, can become 7 distinct molecules (over nine replacements:
|
|
|
|
|
six from H, and three from O).
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
The machine replaces without regard for the surrounding characters. For
|
|
|
|
|
example, given the string H2O, the transition H => OO would result in OO2O.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Your puzzle input describes all of the possible replacements and, at the
|
|
|
|
|
bottom, the medicine molecule for which you need to calibrate the machine.
|
|
|
|
|
How many distinct molecules can be created after all the different ways you
|
|
|
|
|
can do one replacement on the medicine molecule?
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
Your puzzle answer was 518.
|
|
|
|
|
|
|
|
|
|
--- Part Two ---
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Now that the machine is calibrated, you're ready to begin molecule
|
|
|
|
|
fabrication.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Molecule fabrication always begins with just a single electron, e, and
|
|
|
|
|
applying replacements one at a time, just like the ones during calibration.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
For example, suppose you have the following replacements:
|
|
|
|
|
|
|
|
|
|
e => H
|
|
|
|
|
e => O
|
|
|
|
|
H => HO
|
|
|
|
|
H => OH
|
|
|
|
|
O => HH
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
If you'd like to make HOH, you start with e, and then make the following
|
|
|
|
|
replacements:
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
• e => O to get O
|
|
|
|
|
• O => HH to get HH
|
|
|
|
|
• H => OH (on the second H) to get HOH
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
So, you could make HOH after 3 steps. Santa's favorite molecule, HOHOHO, can
|
|
|
|
|
be made in 6 steps.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
How long will it take to make the medicine? Given the available replacements
|
|
|
|
|
and the medicine molecule in your puzzle input, what is the fewest number of
|
|
|
|
|
steps to go from e to the medicine molecule?
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
Your puzzle answer was 200.
|
|
|
|
|
|
|
|
|
|
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/19/input
|