commit 1bcc82c5bfbde87edd03c01ffdf9ee5934681592
parent 277e5d08e28b5fcab8b019f66211883d976efbad
Author: Louis Burda <quent.burda@gmail.com>
Date: Fri, 7 Apr 2023 17:02:32 -0400
Use only highlighted text
Diffstat:
M | 01/part1 | | | 12 | ++++++------ |
M | 01/part2 | | | 52 | ++++++++++++++++++++++------------------------------ |
M | 02/part1 | | | 12 | ++++++------ |
M | 02/part2 | | | 57 | +++++++++++++++++++++++++++++++++++++-------------------- |
M | 03/part1 | | | 12 | ++++++------ |
M | 03/part2 | | | 43 | ++++++++++++++++++++++++++++++++++++++----- |
M | 04/part1 | | | 12 | ++++++------ |
M | 04/part2 | | | 19 | ++++++++++++++----- |
M | 05/part1 | | | 12 | ++++++------ |
M | 05/part2 | | | 77 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------- |
M | 06/part1 | | | 24 | ++++++++++++------------ |
M | 06/part2 | | | 75 | ++++++++++++++++++++++++++++++++++++++++++--------------------------------- |
M | 07/part1 | | | 20 | ++++++++++---------- |
M | 07/part2 | | | 92 | +++++++++++++++++++++++++++++++++++++++++++------------------------------------ |
M | 08/part1 | | | 12 | ++++++------ |
M | 08/part2 | | | 51 | ++++++++++++++++++++++++++++++++------------------- |
M | 09/part1 | | | 90 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
M | 09/part2 | | | 12 | ++++++++++-- |
M | 10/part1 | | | 4 | ++-- |
M | 10/part2 | | | 91 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- |
M | 11/part1 | | | 57 | +++++++++++++++++++++++++++++---------------------------- |
M | 11/part2 | | | 24 | ++++++++---------------- |
M | 12/part1 | | | 12 | ++++++------ |
M | 12/part2 | | | 48 | ++++++++++++++++++++++++++++++++++++++++++++---- |
M | 13/part1 | | | 23 | ++++++++++++----------- |
M | 13/part2 | | | 67 | ++++++++++++++++++++++--------------------------------------------- |
M | 14/part1 | | | 23 | ++++++++++++----------- |
M | 14/part2 | | | 15 | +++++++-------- |
M | 15/part1 | | | 94 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
M | 15/part2 | | | 140 | ++++++++++++++++++++++++++++++------------------------------------------------- |
M | 16/part1 | | | 24 | ++++++++++++------------ |
M | 16/part2 | | | 30 | +++++++++++++++++++++++++++--- |
M | 17/part1 | | | 24 | ++++++++++++------------ |
M | 17/part2 | | | 103 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- |
M | 18/part1 | | | 27 | ++++++++++++++------------- |
M | 18/part2 | | | 182 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- |
M | 19/part1 | | | 20 | ++++++++++---------- |
M | 19/part2 | | | 56 | +++++++++++++++++++++++++++++++++++++++++++++++++++++--- |
M | 20/part1 | | | 44 | ++++++++++++++++++++++---------------------- |
M | 20/part2 | | | 205 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- |
M | 21/part1 | | | 20 | ++++++++++---------- |
M | 21/part2 | | | 26 | ++++++++++++++++++++++---- |
M | 22/part1 | | | 49 | +++++++++++++++++++++++++------------------------ |
M | 22/part2 | | | 306 | ++++--------------------------------------------------------------------------- |
M | 23/part1 | | | 48 | ++++++++++++++++++++++++------------------------ |
M | 23/part2 | | | 33 | ++++++++++++++------------------- |
M | 24/part1 | | | 36 | ++++++++++++++++++------------------ |
M | 24/part2 | | | 328 | ++++++++++++++++++++++++++++++++++++++++++++----------------------------------- |
M | 25/part1 | | | 14 | +++++++------- |
M | 25/part2 | | | 18 | ++++++++++-------- |
50 files changed, 1693 insertions(+), 1182 deletions(-)
diff --git a/01/part1 b/01/part1
@@ -9,14 +9,14 @@ have a device" - she attaches something to your wrist - "that will let you fix t
such propagation delay. It's configured to send you 500 years further into the past every few days;
that was the best we could do on such short notice."
-"The bad news is that we are detecting roughly fifty anomalies throughout time; the device will
-indicate fixed anomalies with stars. The other bad news is that we only have one device and you're
+"The bad news is that we are detecting roughly [1m[97mfifty[0m anomalies throughout time; the device will
+indicate fixed anomalies with [1m[33mstars[0m. The other bad news is that we only have one device and you're
the best person for the job! Good lu--" She taps a button on the device and you suddenly feel like
-you're falling. To save Christmas, you need to get all fifty stars by December 25th.
+you're falling. To save Christmas, you need to get all [1m[33mfifty stars[0m by December 25th.
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!
+calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants
+[1m[33mone star[0m. Good luck!
After feeling like you've been falling for a few minutes, you look at the device's tiny screen.
"Error: Device must be calibrated before first use. Frequency drift detected. Cannot maintain
@@ -49,7 +49,7 @@ Here are other example situations:
- -1, -2, -3 results in -6
-Starting with a frequency of zero, what is the resulting frequency after all of the changes in
+Starting with a frequency of zero, [1m[97mwhat is the resulting frequency[0m after all of the changes in
frequency have been applied?
diff --git a/01/part2 b/01/part2
@@ -1,42 +1,34 @@
--- Part Two ---
-You notice that the device repeats the same frequency change list over and over. To calibrate the
-device, you need to find the first frequency it reaches twice.
+During the second Go / No Go poll, the Elf in charge of the Rocket Equation Double-Checker stops the
+launch sequence. Apparently, you forgot to include additional fuel for the fuel you just added.
-For example, using the same list of changes above, the device would loop as follows:
+Fuel itself requires fuel just like a module - take its mass, divide by three, round down, and
+subtract 2. However, that fuel [1m[97malso[0m requires fuel, and [1m[97mthat[0m fuel requires fuel, and so on. Any
+mass that would require [1m[97mnegative fuel[0m should instead be treated as if it requires [1m[97mzero fuel[0m; the
+remaining mass, if any, is instead handled by [1m[97mwishing really hard[0m, which has no mass and is outside
+the scope of this calculation.
+So, for each module mass, calculate its fuel and add it to the total. Then, treat the fuel amount
+you just calculated as the input mass and repeat the process, continuing until a fuel requirement is
+zero or negative. For example:
- - Current frequency 0, change of +1; resulting frequency 1.
- - Current frequency 1, change of -2; resulting frequency -1.
+ - A module of mass 14 requires 2 fuel. This fuel requires no further fuel (2 divided by 3 and
+rounded down is 0, which would call for a negative fuel), so the total fuel required is still just
+2.
- - Current frequency -1, change of +3; resulting frequency 2.
+ - At first, a module of mass 1969 requires 654 fuel. Then, this fuel requires 216 more fuel (654 /
+3 - 2). 216 then requires 70 more fuel, which requires 21 fuel, which requires 5 fuel, which
+requires no further fuel. So, the total fuel required for a module of mass 1969 is 654 + 216 + 70 +
+21 + 5 = 966.
- - Current frequency 2, change of +1; resulting frequency 3.
+ - The fuel required by a module of mass 100756 and its fuel is: 33583 + 11192 + 3728 + 1240 + 411 +
+135 + 43 + 12 + 2 = 50346.
- - (At this point, the device continues from the start of the list.)
- - Current frequency 3, change of +1; resulting frequency 4.
-
- - Current frequency 4, change of -2; resulting frequency 2, which has already been seen.
-
-
-In this example, the first frequency reached twice is 2. Note that your device might need to repeat
-its list of frequency changes many times before a duplicate frequency is found, and that duplicates
-might be found while in the middle of processing the list.
-
-Here are other examples:
-
-
- - +1, -1 first reaches 0 twice.
-
- - +3, +3, +4, -2, -4 first reaches 10 twice.
-
- - -6, +3, +8, +5, -6 first reaches 5 twice.
-
- - +7, +7, -2, -7, -4 first reaches 14 twice.
-
-
-What is the first frequency your device reaches twice?
+[1m[97mWhat is the sum of the fuel requirements[0m for all of the modules on your spacecraft when also taking
+into account the mass of the added fuel? (Calculate the fuel requirements for each module
+separately, then add them all up at the end.)
diff --git a/02/part1 b/02/part1
@@ -6,22 +6,22 @@ to find those anomalies.
Outside the utility closet, you hear footsteps and a voice. "...I'm not sure either. But now that so
many people have chimneys, maybe he could sneak in that way?" Another voice responds, "Actually,
-we've been working on a new kind of suit that would let him fit through tight spaces like that. But,
+we've been working on a new kind of [1m[97msuit[0m that would let him fit through tight spaces like that. But,
I heard that a few days ago, they lost the prototype fabric, the design plans, everything! Nobody on
the team can even seem to remember important details of the project!"
"Wouldn't they have had enough fabric to fill several boxes in the warehouse? They'd be stored
together, so the box IDs should be similar. Too bad it would take forever to search the warehouse
-for two similar box IDs..." They walk too far away to hear any more.
+for [1m[97mtwo similar box IDs[0m..." They walk too far away to hear any more.
Late at night, you sneak to the warehouse - who knows what kinds of paradoxes you could cause if you
were discovered - and use your fancy wrist device to quickly scan every box and produce a list of
the likely candidates (your puzzle input).
To make sure you didn't miss any, you scan the likely candidate boxes again, counting the number
-that have an ID containing exactly two of any letter and then separately counting those with exactly
-three of any letter. You can multiply those two counts together to get a rudimentary checksum and
-compare it to what your device predicts.
+that have an ID containing [1m[97mexactly two of any letter[0m and then separately counting those with
+[1m[97mexactly three of any letter[0m. You can multiply those two counts together to get a rudimentary
+checksum and compare it to what your device predicts.
For example, if you see the following box IDs:
@@ -45,6 +45,6 @@ Of these box IDs, four of them contain a letter which appears exactly twice, and
contain a letter which appears exactly three times. Multiplying these together produces a checksum
of 4 * 3 = 12.
-What is the checksum for your list of box IDs?
+[1m[97mWhat is the checksum[0m for your list of box IDs?
diff --git a/02/part2 b/02/part2
@@ -1,24 +1,41 @@
--- Part Two ---
-Confident that your list of box IDs is complete, you're ready to find the boxes full of prototype
-fabric.
-
-The boxes will have IDs which differ by exactly one character at the same position in both strings.
-For example, given the following box IDs:
-
-abcde
-fghij
-klmno
-pqrst
-fguij
-axcye
-wvxyz
-
-The IDs abcde and axcye are close, but they differ by two characters (the second and fourth).
-However, the IDs fghij and fguij differ by exactly one character, the third (h and u). Those must be
-the correct boxes.
-
-What letters are common between the two correct box IDs? (In the example above, this is found by
-removing the differing character from either ID, producing fgij.)
+"Good, the new computer seems to be working correctly! [1m[97mKeep it nearby[0m during this mission - you'll
+probably use it again. Real Intcode computers support many more features than your new one, but
+we'll let you know what they are as you need them."
+
+"However, your current priority should be to complete your gravity assist around the Moon. For this
+mission to succeed, we should settle on some terminology for the parts you've already built."
+
+Intcode programs are given as a list of integers; these values are used as the initial state for the
+computer's [1m[97mmemory[0m. When you run an Intcode program, make sure to start by initializing memory to the
+program's values. A position in memory is called an [1m[97maddress[0m (for example, the first value in memory
+is at "address 0").
+
+Opcodes (like 1, 2, or 99) mark the beginning of an [1m[97minstruction[0m. The values used immediately after
+an opcode, if any, are called the instruction's [1m[97mparameters[0m. For example, in the instruction
+1,2,3,4, 1 is the opcode; 2, 3, and 4 are the parameters. The instruction 99 contains only an opcode
+and has no parameters.
+
+The address of the current instruction is called the [1m[97minstruction pointer[0m; it starts at 0. After an
+instruction finishes, the instruction pointer increases by [1m[97mthe number of values in the
+instruction[0m; until you add more instructions to the computer, this is always 4 (1 opcode + 3
+parameters) for the add and multiply instructions. (The halt instruction would increase the
+instruction pointer by 1, but it halts the program instead.)
+
+"With terminology out of the way, we're ready to proceed. To complete the gravity assist, you need
+to [1m[97mdetermine what pair of inputs produces the output 19690720[0m."
+
+The inputs should still be provided to the program by replacing the values at addresses 1 and 2,
+just like before. In this program, the value placed in address 1 is called the [1m[97mnoun[0m, and the value
+placed in address 2 is called the [1m[97mverb[0m. Each of the two input values will be between 0 and 99,
+inclusive.
+
+Once the program has halted, its output is available at address 0, also just like before. Each time
+you try a pair of inputs, make sure you first [1m[97mreset the computer's memory to the values in the
+program[0m (your puzzle input) - in other words, don't reuse memory from a previous attempt.
+
+Find the input [1m[97mnoun[0m and [1m[97mverb[0m that cause the program to produce the output 19690720. [1m[97mWhat is 100 *
+noun + verb?[0m (For example, if noun=12 and verb=2, the answer would be 1202.)
diff --git a/03/part1 b/03/part1
@@ -2,12 +2,12 @@
The Elves managed to locate the chimney-squeeze prototype fabric for Santa's suit (thanks to someone
who helpfully wrote its box IDs on the wall of the warehouse in the middle of the night).
-Unfortunately, anomalies are still affecting them - nobody can even agree on how to cut the fabric.
+Unfortunately, anomalies are still affecting them - nobody can even agree on how to [1m[97mcut[0m the fabric.
The whole piece of fabric they're working on is a very large square - at least 1000 inches on each
side.
-Each Elf has made a claim about which area of fabric would be ideal for Santa's suit. All claims
+Each Elf has made a [1m[97mclaim[0m about which area of fabric would be ideal for Santa's suit. All claims
have an ID and consist of a single rectangle with edges parallel to the edges of the fabric. Each
claim's rectangle is defined as follows:
@@ -36,7 +36,7 @@ diagram below:
...........
...........
-The problem is that many of the claims overlap, causing two or more claims to cover part of the same
+The problem is that many of the claims [1m[97moverlap[0m, causing two or more claims to cover part of the same
areas. For example, consider the following claims:
#1 @ 1,3: 4x4
@@ -54,10 +54,10 @@ Visually, these claim the following areas:
.111133.
........
-The four square inches marked with X are claimed by both 1 and 2. (Claim 3, while adjacent to the
+The four square inches marked with X are claimed by [1m[97mboth 1 and 2[0m. (Claim 3, while adjacent to the
others, does not overlap either of them.)
-If the Elves all proceed with their own plans, none of them will have enough fabric. How many square
-inches of fabric are within two or more claims?
+If the Elves all proceed with their own plans, none of them will have enough fabric. [1m[97mHow many square
+inches of fabric are within two or more claims?[0m
diff --git a/03/part2 b/03/part2
@@ -1,11 +1,44 @@
--- Part Two ---
-Amidst the chaos, you notice that exactly one claim doesn't overlap by even a single square inch of
-fabric with any other claim. If you can somehow draw attention to it, maybe the Elves will be able
-to make Santa's suit after all!
+It turns out that this circuit is very timing-sensitive; you actually need to [1m[97mminimize the signal
+delay[0m.
-For example, in the claims above, only claim 3 is intact after all claims are made.
+To do this, calculate the [1m[97mnumber of steps[0m each wire takes to reach each intersection; choose the
+intersection where the [1m[97msum of both wires' steps[0m is lowest. If a wire visits a position on the grid
+multiple times, use the steps value from the [1m[97mfirst[0m time it visits that position when calculating the
+total value of a specific intersection.
-What is the ID of the only claim that doesn't overlap?
+The number of steps a wire takes is the total number of grid squares the wire has entered to get to
+that location, including the intersection being considered. Again consider the example from above:
+
+...........
+.+-----+...
+.|.....|...
+.|..+--X-+.
+.|..|..|.|.
+.|.-X--+.|.
+.|..|....|.
+.|.......|.
+.o-------+.
+...........
+
+In the above example, the intersection closest to the central port is reached after 8+5+5+2 =
+[1m[97m20[0m steps by the first wire and 7+6+4+3 = [1m[97m20[0m steps by the second wire for a total of 20+20 =
+[1m[97m40[0m steps.
+
+However, the top-right intersection is better: the first wire takes only 8+5+2 = [1m[97m15[0m and the second
+wire takes only 7+6+2 = [1m[97m15[0m, a total of 15+15 = [1m[97m30[0m steps.
+
+Here are the best steps for the extra examples from above:
+
+
+ - R75,D30,R83,U83,L12,D49,R71,U7,L72
+U62,R66,U55,R34,D71,R55,D58,R83 = 610 steps
+
+ - R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51
+U98,R91,D20,R16,D67,R40,U7,R15,U6,R7 = 410 steps
+
+
+[1m[97mWhat is the fewest combined steps the wires must take to reach an intersection?[0m
diff --git a/04/part1 b/04/part1
@@ -6,8 +6,8 @@ stationed outside the lab, so this is as close as you can safely get.
As you search the closet for anything that might help, you discover that you're not the first person
to want to sneak in. Covering the walls, someone has spent an hour starting every midnight for the
-past few months secretly observing this guard post! They've been writing down the ID of the one
-guard on duty that night - the Elves seem to have decided that one guard was enough for the
+past few months secretly observing this guard post! They've been writing down the ID of
+[1m[97mthe one guard on duty that night[0m - the Elves seem to have decided that one guard was enough for the
overnight shift - as well as when they fall asleep or wake up while at their post (your puzzle
input).
@@ -60,17 +60,17 @@ If you can figure out the guard most likely to be asleep at a specific time, you
trick that guard into working tonight so you can have the best chance of sneaking in. You have two
strategies for choosing the best guard/minute combination.
-Strategy 1: Find the guard that has the most minutes asleep. What minute does that guard spend
+[1m[97mStrategy 1:[0m Find the guard that has the most minutes asleep. What minute does that guard spend
asleep the most?
In the example above, Guard #10 spent the most minutes asleep, a total of 50 minutes (20+25+5),
-while Guard #99 only slept for a total of 30 minutes (10+10+10). Guard #10 was asleep most during
-minute 24 (on two days, whereas any other minute the guard was asleep was only seen on one day).
+while Guard #99 only slept for a total of 30 minutes (10+10+10). Guard #[1m[97m10[0m was asleep most during
+minute [1m[97m24[0m (on two days, whereas any other minute the guard was asleep was only seen on one day).
While this example listed the entries in chronological order, your entries are in the order you
found them. You'll need to organize them before they can be analyzed.
-What is the ID of the guard you chose multiplied by the minute you chose? (In the above example, the
+[1m[97mWhat is the ID of the guard you chose multiplied by the minute you chose?[0m (In the above example, the
answer would be 10 * 24 = 240.)
diff --git a/04/part2 b/04/part2
@@ -1,11 +1,20 @@
--- Part Two ---
-Strategy 2: Of all guards, which guard is most frequently asleep on the same minute?
+An Elf just remembered one more important detail: the two adjacent matching digits [1m[97mare not part of a
+larger group of matching digits[0m.
-In the example above, Guard #99 spent minute 45 asleep more than any other guard or minute - three
-times in total. (In all other cases, any guard spent any minute asleep at most twice.)
+Given this additional criterion, but still ignoring the range rule, the following are now true:
-What is the ID of the guard you chose multiplied by the minute you chose? (In the above example, the
-answer would be 99 * 45 = 4455.)
+
+ - 112233 meets these criteria because the digits never decrease and all repeated digits are exactly
+two digits long.
+
+ - 123[1m[97m444[0m no longer meets the criteria (the repeated 44 is part of a larger group of 444).
+
+ - 111122 meets the criteria (even though 1 is repeated more than twice, it still contains a double
+22).
+
+
+[1m[97mHow many different passwords[0m within the range given in your puzzle input meet all of the criteria?
diff --git a/05/part1 b/05/part1
@@ -7,7 +7,7 @@ While the very latest in 1518 alchemical technology might have solved their prob
can do better. You scan the chemical composition of the suit's material and discover that it is
formed by extremely long polymers (one of which is available as your puzzle input).
-The polymer is formed by smaller units which, when triggered, react with each other such that two
+The polymer is formed by smaller [1m[97munits[0m which, when triggered, react with each other such that two
adjacent units of the same type and opposite polarity are destroyed. Units' types are represented by
letters; units' polarity is represented by capitalization. For instance, r and R are units with the
same type but opposite polarity, whereas r and s are entirely different types and do not react.
@@ -27,14 +27,14 @@ happens.
Now, consider a larger example, dabAcCaCBAcCcaDA:
-dabAcCaCBAcCcaDA The first 'cC' is removed.
-dabAaCBAcCcaDA This creates 'Aa', which is removed.
-dabCBAcCcaDA Either 'cC' or 'Cc' are removed (the result is the same).
+dabA[1m[97mcC[0maCBAcCcaDA The first 'cC' is removed.
+dab[1m[97mAa[0mCBAcCcaDA This creates 'Aa', which is removed.
+dabCBA[1m[97mcCc[0maDA Either 'cC' or 'Cc' are removed (the result is the same).
dabCBAcaDA No further actions can be taken.
-After all possible reactions, the resulting polymer contains 10 units.
+After all possible reactions, the resulting polymer contains [1m[97m10 units[0m.
-How many units remain after fully reacting the polymer you scanned? (Note: in this puzzle and
+[1m[97mHow many units remain after fully reacting the polymer you scanned?[0m (Note: in this puzzle and
others, the input is large; if you copy/paste your input, make sure you get the whole thing.)
diff --git a/05/part2 b/05/part2
@@ -1,30 +1,75 @@
--- Part Two ---
-Time to improve the polymer.
+The air conditioner comes online! Its cold air feels good for a while, but then the TEST alarms
+start to go off. Since the air conditioner can't vent its heat anywhere but back into the
+spacecraft, it's actually making the air inside the ship [1m[97mwarmer[0m.
-One of the unit types is causing problems; it's preventing the polymer from collapsing as much as it
-should. Your goal is to figure out which unit type is causing the most problems, remove all
-instances of it (regardless of polarity), fully react the remaining polymer, and measure its length.
+Instead, you'll need to use the TEST to extend the thermal radiators. Fortunately, the diagnostic
+program (your puzzle input) is already equipped for this. Unfortunately, your Intcode computer is
+not.
-For example, again using the polymer dabAcCaCBAcCcaDA from above:
+Your computer is only missing a few opcodes:
- - Removing all A/a units produces dbcCCBcCcD. Fully reacting this polymer produces dbCBcD, which
-has length 6.
+ - Opcode 5 is [1m[97mjump-if-true[0m: if the first parameter is [1m[97mnon-zero[0m, it sets the instruction pointer to
+the value from the second parameter. Otherwise, it does nothing.
- - Removing all B/b units produces daAcCaCAcCcaDA. Fully reacting this polymer produces daCAcaDA,
-which has length 8.
+ - Opcode 6 is [1m[97mjump-if-false[0m: if the first parameter [1m[97mis zero[0m, it sets the instruction pointer to the
+value from the second parameter. Otherwise, it does nothing.
- - Removing all C/c units produces dabAaBAaDA. Fully reacting this polymer produces daDA, which has
-length 4.
+ - Opcode 7 is [1m[97mless than[0m: if the first parameter is [1m[97mless than[0m the second parameter, it stores 1 in
+the position given by the third parameter. Otherwise, it stores 0.
- - Removing all D/d units produces abAcCaCBAcCcaA. Fully reacting this polymer produces abCBAc,
-which has length 6.
+ - Opcode 8 is [1m[97mequals[0m: if the first parameter is [1m[97mequal to[0m the second parameter, it stores 1 in the
+position given by the third parameter. Otherwise, it stores 0.
-In this example, removing all C/c units was best, producing the answer 4.
+Like all instructions, these instructions need to support [1m[97mparameter modes[0m as described above.
-What is the length of the shortest polymer you can produce by removing all units of exactly one type
-and fully reacting the result?
+Normally, after an instruction is finished, the instruction pointer increases by the number of
+values in that instruction. [1m[97mHowever[0m, if the instruction modifies the instruction pointer, that value
+is used and the instruction pointer is [1m[97mnot automatically increased[0m.
+
+For example, here are several programs that take one input, compare it to the value 8, and then
+produce one output:
+
+
+ - 3,9,8,9,10,9,4,9,99,-1,8 - Using [1m[97mposition mode[0m, consider whether the input is [1m[97mequal to[0m 8; output
+1 (if it is) or 0 (if it is not).
+
+ - 3,9,7,9,10,9,4,9,99,-1,8 - Using [1m[97mposition mode[0m, consider whether the input is [1m[97mless than[0m 8; output
+1 (if it is) or 0 (if it is not).
+
+ - 3,3,1108,-1,8,3,4,3,99 - Using [1m[97mimmediate mode[0m, consider whether the input is [1m[97mequal to[0m 8; output 1
+(if it is) or 0 (if it is not).
+
+ - 3,3,1107,-1,8,3,4,3,99 - Using [1m[97mimmediate mode[0m, consider whether the input is [1m[97mless than [0m8; output
+1 (if it is) or 0 (if it is not).
+
+
+Here are some jump tests that take an input, then output 0 if the input was zero or 1 if the input
+was non-zero:
+
+
+ - 3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9 (using [1m[97mposition mode[0m)
+
+ - 3,3,1105,-1,9,1101,0,0,12,4,12,99,1 (using [1m[97mimmediate mode[0m)
+
+
+Here's a larger example:
+
+3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,
+1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,
+999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99
+
+The above example program uses an input instruction to ask for a single number. The program will
+then output 999 if the input value is below 8, output 1000 if the input value is equal to 8, or
+output 1001 if the input value is greater than 8.
+
+This time, when the TEST diagnostic program runs its input instruction to get the ID of the system
+to test, [1m[97mprovide it 5[0m, the ID for the ship's thermal radiator controller. This diagnostic test suite
+only outputs one number, the [1m[97mdiagnostic code[0m.
+
+[1m[97mWhat is the diagnostic code for system ID 5?[0m
diff --git a/06/part1 b/06/part1
@@ -8,14 +8,14 @@ detected. Please specify new target coordinates."
The device then produces a list of coordinates (your puzzle input). Are they places it thinks are
safe or dangerous? It recommends you check manual page 729. The Elves did not give you a manual.
-If they're dangerous, maybe you can minimize the danger by finding the coordinate that gives the
+[1m[97mIf they're dangerous,[0m maybe you can minimize the danger by finding the coordinate that gives the
largest distance from the other points.
-Using only the Manhattan distance, determine the area around each coordinate by counting the number
-of integer X,Y locations that are closest to that coordinate (and aren't tied in distance to any
+Using only the Manhattan distance, determine the [1m[97marea[0m around each coordinate by counting the number
+of integer X,Y locations that are [1m[97mclosest[0m to that coordinate (and aren't [1m[97mtied in distance[0m to any
other coordinate).
-Your goal is to find the size of the largest area that isn't infinite. For example, consider the
+Your goal is to find the size of the [1m[97mlargest area[0m that isn't infinite. For example, consider the
following list of coordinates:
1, 1
@@ -42,15 +42,15 @@ This view is partial - the actual grid extends infinitely in all directions. Us
distance, each location's closest coordinate can be determined, shown here in lowercase:
aaaaa.cccc
-aAaaa.cccc
+a[1m[97mA[0maaa.cccc
aaaddecccc
-aadddeccCc
-..dDdeeccc
-bb.deEeecc
-bBb.eeee..
+aadddecc[1m[97mC[0mc
+..d[1m[97mD[0mdeeccc
+bb.de[1m[97mE[0meecc
+b[1m[97mB[0mb.eeee..
bbb.eeefff
bbb.eeffff
-bbb.ffffFf
+bbb.ffff[1m[97mF[0mf
Locations shown as . are equally far from two or more coordinates, and so they don't count as being
closest to any.
@@ -58,8 +58,8 @@ closest to any.
In this example, the areas of coordinates A, B, C, and F are infinite - while not shown here, their
areas extend forever outside the visible grid. However, the areas of coordinates D and E are finite:
D is closest to 9 locations, and E is closest to 17 (both including the coordinate's location
-itself). Therefore, in this example, the size of the largest area is 17.
+itself). Therefore, in this example, the size of the largest area is [1m[97m17[0m.
-What is the size of the largest area that isn't infinite?
+[1m[97mWhat is the size of the largest area[0m that isn't infinite?
diff --git a/06/part2 b/06/part2
@@ -1,52 +1,61 @@
--- Part Two ---
-On the other hand, if the coordinates are safe, maybe the best you can do is try to find a region
-near as many coordinates as possible.
+Now, you just need to figure out how many [1m[97morbital transfers[0m you (YOU) need to take to get to Santa
+(SAN).
-For example, suppose you want the sum of the Manhattan distance to all of the coordinates to be less
-than 32. For each location, add up the distances to all of the given coordinates; if the total of
-those distances is less than 32, that location is within the desired region. Using the same
-coordinates as above, the resulting region looks like this:
+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.
-..........
-.A........
-..........
-...###..C.
-..#D###...
-..###E#...
-.B.###....
-..........
-..........
-........F.
+For example, suppose you have the following map:
-In particular, consider the highlighted location 4,3 located at the top middle of the region. Its
-calculation is as follows, where abs() is the absolute value function:
+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
+Visually, the above map of orbits looks like this:
- - Distance to coordinate A: abs(4-1) + abs(3-1) = 5
+ [1m[97mYOU[0m
+ [1m[97m/[0m
+ G - H [1m[97mJ - K[0m - L
+ / [1m[97m/[0m
+COM - B - C - [1m[97mD - E[0m - F
+ [1m[97m\[0m
+ [1m[97mI - SAN[0m
- - Distance to coordinate B: abs(4-1) + abs(3-6) = 6
+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:
- - Distance to coordinate C: abs(4-8) + abs(3-3) = 4
- - Distance to coordinate D: abs(4-3) + abs(3-4) = 2
+ - K to J
- - Distance to coordinate E: abs(4-5) + abs(3-5) = 3
+ - J to E
- - Distance to coordinate F: abs(4-8) + abs(3-9) = 10
+ - E to D
- - Total distance: 5 + 6 + 4 + 2 + 3 + 10 = 30
+ - D to I
-Because the total distance to all coordinates (30) is less than 32, the location is within the
-region.
+Afterward, the map of orbits looks like this:
-This region, which also includes coordinates D and E, has a total size of 16.
+ G - H J - K - L
+ / /
+COM - B - C - D - E - F
+ \
+ I - SAN
+ [1m[97m\[0m
+ [1m[97mYOU[0m
-Your actual region will need to be much larger than this example, though, instead including all
-locations with a total distance of less than 10000.
-
-What is the size of the region containing all locations which have a total distance to all given
-coordinates of less than 10000?
+[1m[97mWhat is the minimum number of orbital transfers required[0m to move from the object YOU are orbiting to
+the object SAN is orbiting? (Between the objects they are orbiting - [1m[97mnot[0m between YOU and SAN.)
diff --git a/07/part1 b/07/part1
@@ -18,7 +18,7 @@ required."
"'Sleigh'? What a wonderful name! You must help us assemble this 'sleigh' at once!" They start
excitedly pulling more parts out of the box.
-The instructions specify a series of steps and requirements about which steps must be finished
+The instructions specify a series of [1m[97msteps[0m and requirements about which steps must be finished
before others can begin (your puzzle input). Each step is designated by a single letter. For
example, suppose you have the following instructions:
@@ -43,23 +43,23 @@ step is ready, choose the step which is first alphabetically. In this example, t
completed as follows:
- - Only C is available, and so it is done first.
+ - Only [1m[97mC[0m is available, and so it is done first.
- - Next, both A and F are available. A is first alphabetically, so it is done next.
+ - Next, both A and F are available. [1m[97mA[0m is first alphabetically, so it is done next.
- - Then, even though F was available earlier, steps B and D are now also available, and B is the
-first alphabetically of the three.
+ - Then, even though F was available earlier, steps B and D are now also available, and
+[1m[97mB[0m is the first alphabetically of the three.
- After that, only D and F are available. E is not available because only some of its prerequisites
-are complete. Therefore, D is completed next.
+are complete. Therefore, [1m[97mD[0m is completed next.
- - F is the only choice, so it is done next.
+ - [1m[97mF[0m is the only choice, so it is done next.
- - Finally, E is completed.
+ - Finally, [1m[97mE[0m is completed.
-So, in this example, the correct order is CABDFE.
+So, in this example, the correct order is [1m[97mCABDFE[0m.
-In what order should the steps in your instructions be completed?
+[1m[97mIn what order should the steps in your instructions be completed?[0m
diff --git a/07/part2 b/07/part2
@@ -1,46 +1,54 @@
--- Part Two ---
-As you're about to begin construction, four of the Elves offer to help. "The sun will set soon;
-it'll go faster if we work together." Now, you need to account for multiple people working on steps
-simultaneously. If multiple steps are available, workers should still begin them in alphabetical
-order.
-
-Each step takes 60 seconds plus an amount corresponding to its letter: A=1, B=2, C=3, and so on. So,
-step A takes 60+1=61 seconds, while step Z takes 60+26=86 seconds. No time is required between
-steps.
-
-To simplify things for the example, however, suppose you only have help from one Elf (a total of two
-workers) and that each step takes 60 fewer seconds (so that step A takes 1 second and step Z takes
-26 seconds). Then, using the same instructions as above, this is how each second would be spent:
-
-Second Worker 1 Worker 2 Done
- 0 C .
- 1 C .
- 2 C .
- 3 A F C
- 4 B F CA
- 5 B F CA
- 6 D F CAB
- 7 D F CAB
- 8 D F CAB
- 9 D . CABF
- 10 E . CABFD
- 11 E . CABFD
- 12 E . CABFD
- 13 E . CABFD
- 14 E . CABFD
- 15 . . CABFDE
-
-Each row represents one second of time. The Second column identifies how many seconds have passed
-as of the beginning of that second. Each worker column shows the step that worker is currently
-doing (or . if they are idle). The Done column shows completed steps.
-
-Note that the order of the steps has changed; this is because steps now take time to finish and
-multiple workers can begin multiple steps simultaneously.
-
-In this example, it would take 15 seconds for two workers to complete these steps.
-
-With 5 workers and the 60+ second step durations described above, how long will it take to complete
-all of the steps?
+It's no good - in this configuration, the amplifiers can't generate a large enough output signal to
+produce the thrust you'll need. The Elves quickly talk you through rewiring the amplifiers into a
+[1m[97mfeedback loop[0m:
+
+ O-------O O-------O O-------O O-------O O-------O
+0 -+->| Amp A |->| Amp B |->| Amp C |->| Amp D |->| Amp E |-.
+ | O-------O O-------O O-------O O-------O O-------O |
+ | |
+ '--------------------------------------------------------+
+ |
+ v
+ (to thrusters)
+
+Most of the amplifiers are connected as they were before; amplifier A's output is connected to
+amplifier B's input, and so on. [1m[97mHowever,[0m the output from amplifier E is now connected into amplifier
+A's input. This creates the feedback loop: the signal will be sent through the amplifiers
+[1m[97mmany times[0m.
+
+In feedback loop mode, the amplifiers need [1m[97mtotally different phase settings[0m: integers from 5 to 9,
+again each used exactly once. These settings will cause the Amplifier Controller Software to
+repeatedly take input and produce output many times before halting. Provide each amplifier its phase
+setting at its first input instruction; all further input/output instructions are for signals.
+
+Don't restart the Amplifier Controller Software on any amplifier during this process. Each one
+should continue receiving and sending signals until it halts.
+
+All signals sent or received in this process will be between pairs of amplifiers except the very
+first signal and the very last signal. To start the process, a 0 signal is sent to amplifier A's
+input [1m[97mexactly once[0m.
+
+Eventually, the software on the amplifiers will halt after they have processed the final loop. When
+this happens, the last output signal from amplifier E is sent to the thrusters. Your job is to
+[1m[97mfind the largest output signal that can be sent to the thrusters[0m using the new phase settings and
+feedback loop arrangement.
+
+Here are some example programs:
+
+
+ - Max thruster signal [1m[97m139629729[0m (from phase setting sequence 9,8,7,6,5):
+3,26,1001,26,-4,26,3,27,1002,27,2,27,1,27,26,
+27,4,27,1001,28,-1,28,1005,28,6,99,0,0,5
+
+ - Max thruster signal [1m[97m18216[0m (from phase setting sequence 9,7,8,5,6):
+3,52,1001,52,-5,52,3,53,1,52,56,54,1007,54,5,55,1005,55,26,1001,54,
+-5,54,1105,1,12,1,53,54,53,1008,54,0,55,1001,55,1,55,2,53,55,53,4,
+53,1001,56,-1,56,1005,56,6,99,0,0,0,0,10
+
+
+Try every combination of the new phase settings on the amplifier feedback loop. [1m[97mWhat is the highest
+signal that can be sent to the thrusters?[0m
diff --git a/08/part1 b/08/part1
@@ -11,22 +11,22 @@ The navigation system's license file consists of a list of numbers (your puzzle
define a data structure which, when processed, produces some kind of tree that can be used to
calculate the license number.
-The tree is made up of nodes; a single, outermost node forms the tree's root, and it contains all
+The [1m[97mtree[0m is made up of [1m[97mnodes[0m; a single, outermost node forms the tree's [1m[97mroot[0m, and it contains all
other nodes in the tree (or contains nodes that contain nodes, and so on).
Specifically, a node consists of:
- - A header, which is always exactly two numbers:
+ - A [1m[97mheader[0m, which is always exactly two numbers:
- The quantity of child nodes.
- The quantity of metadata entries.
- - Zero or more child nodes (as specified in the header).
+ - Zero or more [1m[97mchild nodes[0m (as specified in the header).
- - One or more metadata entries (as specified in the header).
+ - One or more [1m[97mmetadata entries[0m (as specified in the header).
@@ -51,8 +51,8 @@ easier identification. In it, there are four nodes:
The first check done on the license file is to simply add up all of the metadata entries. In this
-example, that sum is 1+1+2+10+11+12+2+99=138.
+example, that sum is 1+1+2+10+11+12+2+99=[1m[97m138[0m.
-What is the sum of all metadata entries?
+[1m[97mWhat is the sum of all metadata entries?[0m
diff --git a/08/part2 b/08/part2
@@ -1,33 +1,46 @@
--- Part Two ---
-The second check is slightly more complicated: you need to find the value of the root node (A in the
-example above).
+Now you're ready to decode the image. The image is rendered by stacking the layers and aligning the
+pixels with the same positions in each layer. The digits indicate the color of the corresponding
+pixel: 0 is black, 1 is white, and 2 is transparent.
-The value of a node depends on whether it has child nodes.
+The layers are rendered with the first layer in front and the last layer in back. So, if a given
+position has a transparent pixel in the first and second layers, a black pixel in the third layer,
+and a white pixel in the fourth layer, the final image would have a [1m[97mblack[0m pixel at that position.
-If a node has no child nodes, its value is the sum of its metadata entries. So, the value of node B
-is 10+11+12=33, and the value of node D is 99.
+For example, given an image 2 pixels wide and 2 pixels tall, the image data 0222112222120000
+corresponds to the following image layers:
-However, if a node does have child nodes, the metadata entries become indexes which refer to those
-child nodes. A metadata entry of 1 refers to the first child node, 2 to the second, 3 to the third,
-and so on. The value of this node is the sum of the values of the child nodes referenced by the
-metadata entries. If a referenced child node does not exist, that reference is skipped. A child node
-can be referenced multiple time and counts each time it is referenced. A metadata entry of 0 does
-not refer to any child node.
+Layer 1: [1m[97m0[0m2
+ 22
-For example, again using the above nodes:
+Layer 2: 1[1m[97m1[0m
+ 22
+Layer 3: 22
+ [1m[97m1[0m2
- - Node C has one metadata entry, 2. Because node C has only one child node, 2 references a child
-node which does not exist, and so the value of node C is 0.
+Layer 4: 00
+ 0[1m[97m0[0m
- - Node A has three metadata entries: 1, 1, and 2. The 1 references node A's first child node, B,
-and the 2 references node A's second child node, C. Because node B has a value of 33 and node C has
-a value of 0, the value of node A is 33+33+0=66.
+Then, the full image can be found by determining the top visible pixel in each position:
-So, in this example, the value of the root node is 66.
+ - The top-left pixel is [1m[97mblack[0m because the top layer is 0.
-What is the value of the root node?
+ - The top-right pixel is [1m[97mwhite[0m because the top layer is 2 (transparent), but the second layer is 1.
+
+ - The bottom-left pixel is [1m[97mwhite[0m because the top two layers are 2, but the third layer is 1.
+
+ - The bottom-right pixel is [1m[97mblack[0m because the only visible pixel in that position is 0 (from layer
+4).
+
+
+So, the final image looks like this:
+
+01
+10
+
+[1m[97mWhat message is produced after decoding your image?[0m
diff --git a/09/part1 b/09/part1
@@ -3,76 +3,76 @@
You talk to the Elves while you wait for your navigation system to initialize. To pass the time,
they introduce you to their favorite marble game.
-The Elves play this game by taking turns arranging the marbles in a circle according to very
+The Elves play this game by taking turns arranging the marbles in a [1m[97mcircle[0m according to very
particular rules. The marbles are numbered starting with 0 and increasing by 1 until every marble
has a number.
First, the marble numbered 0 is placed in the circle. At this point, while it contains only a single
marble, it is still a circle: the marble is both clockwise from itself and counter-clockwise from
-itself. This marble is designated the current marble.
+itself. This marble is designated the [1m[97mcurrent marble[0m.
-Then, each Elf takes a turn placing the lowest-numbered remaining marble into the circle between the
-marbles that are 1 and 2 marbles clockwise of the current marble. (When the circle is large enough,
+Then, each Elf takes a turn placing the [1m[97mlowest-numbered remaining marble[0m into the circle between the
+marbles that are 1 and 2 marbles [1m[97mclockwise[0m of the current marble. (When the circle is large enough,
this means that there is one marble between the marble that was just placed and the current marble.)
-The marble that was just placed then becomes the current marble.
+The marble that was just placed then becomes the [1m[97mcurrent marble[0m.
-However, if the marble that is about to be placed has a number which is a multiple of 23, something
-entirely different happens. First, the current player keeps the marble they would have placed,
-adding it to their score. In addition, the marble 7 marbles counter-clockwise from the current
-marble is removed from the circle and also added to the current player's score. The marble located
-immediately clockwise of the marble that was removed becomes the new current marble.
+However, if the marble that is about to be placed has a number which is a multiple of 23,
+[1m[97msomething entirely different happens[0m. First, the current player keeps the marble they would have
+placed, adding it to their [1m[97mscore[0m. In addition, the marble 7 marbles [1m[97mcounter-clockwise[0m from the
+current marble is [1m[97mremoved[0m from the circle and [1m[97malso[0m added to the current player's score. The marble
+located immediately [1m[97mclockwise[0m of the marble that was removed becomes the new [1m[97mcurrent marble[0m.
For example, suppose there are 9 players. After the marble with value 0 is placed in the middle,
each player (shown in square brackets) takes a turn. The result of each of those turns would produce
circles of marbles like this, where clockwise is to the right and the resulting current marble is in
parentheses:
-[-] (0)
-[1] 0 (1)
-[2] 0 (2) 1
-[3] 0 2 1 (3)
-[4] 0 (4) 2 1 3
-[5] 0 4 2 (5) 1 3
-[6] 0 4 2 5 1 (6) 3
-[7] 0 4 2 5 1 6 3 (7)
-[8] 0 (8) 4 2 5 1 6 3 7
-[9] 0 8 4 (9) 2 5 1 6 3 7
-[1] 0 8 4 9 2(10) 5 1 6 3 7
-[2] 0 8 4 9 2 10 5(11) 1 6 3 7
-[3] 0 8 4 9 2 10 5 11 1(12) 6 3 7
-[4] 0 8 4 9 2 10 5 11 1 12 6(13) 3 7
-[5] 0 8 4 9 2 10 5 11 1 12 6 13 3(14) 7
-[6] 0 8 4 9 2 10 5 11 1 12 6 13 3 14 7(15)
-[7] 0(16) 8 4 9 2 10 5 11 1 12 6 13 3 14 7 15
-[8] 0 16 8(17) 4 9 2 10 5 11 1 12 6 13 3 14 7 15
-[9] 0 16 8 17 4(18) 9 2 10 5 11 1 12 6 13 3 14 7 15
-[1] 0 16 8 17 4 18 9(19) 2 10 5 11 1 12 6 13 3 14 7 15
-[2] 0 16 8 17 4 18 9 19 2(20)10 5 11 1 12 6 13 3 14 7 15
-[3] 0 16 8 17 4 18 9 19 2 20 10(21) 5 11 1 12 6 13 3 14 7 15
-[4] 0 16 8 17 4 18 9 19 2 20 10 21 5(22)11 1 12 6 13 3 14 7 15
-[5] 0 16 8 17 4 18(19) 2 20 10 21 5 22 11 1 12 6 13 3 14 7 15
-[6] 0 16 8 17 4 18 19 2(24)20 10 21 5 22 11 1 12 6 13 3 14 7 15
-[7] 0 16 8 17 4 18 19 2 24 20(25)10 21 5 22 11 1 12 6 13 3 14 7 15
-
-The goal is to be the player with the highest score after the last marble is used up. Assuming the
-example above ends after the marble numbered 25, the winning score is 23+9=32 (because player 5 kept
+[-] [1m[97m(0)[0m
+[1] 0[1m[97m (1)[0m
+[2] 0[1m[97m (2)[0m 1
+[3] 0 2 1[1m[97m (3)[0m
+[4] 0[1m[97m (4)[0m 2 1 3
+[5] 0 4 2[1m[97m (5)[0m 1 3
+[6] 0 4 2 5 1[1m[97m (6)[0m 3
+[7] 0 4 2 5 1 6 3[1m[97m (7)[0m
+[8] 0[1m[97m (8)[0m 4 2 5 1 6 3 7
+[9] 0 8 4[1m[97m (9)[0m 2 5 1 6 3 7
+[1] 0 8 4 9 2[1m[97m(10)[0m 5 1 6 3 7
+[2] 0 8 4 9 2 10 5[1m[97m(11)[0m 1 6 3 7
+[3] 0 8 4 9 2 10 5 11 1[1m[97m(12)[0m 6 3 7
+[4] 0 8 4 9 2 10 5 11 1 12 6[1m[97m(13)[0m 3 7
+[5] 0 8 4 9 2 10 5 11 1 12 6 13 3[1m[97m(14)[0m 7
+[6] 0 8 4 9 2 10 5 11 1 12 6 13 3 14 7[1m[97m(15)[0m
+[7] 0[1m[97m(16)[0m 8 4 9 2 10 5 11 1 12 6 13 3 14 7 15
+[8] 0 16 8[1m[97m(17)[0m 4 9 2 10 5 11 1 12 6 13 3 14 7 15
+[9] 0 16 8 17 4[1m[97m(18)[0m 9 2 10 5 11 1 12 6 13 3 14 7 15
+[1] 0 16 8 17 4 18 9[1m[97m(19)[0m 2 10 5 11 1 12 6 13 3 14 7 15
+[2] 0 16 8 17 4 18 9 19 2[1m[97m(20)[0m10 5 11 1 12 6 13 3 14 7 15
+[3] 0 16 8 17 4 18 9 19 2 20 10[1m[97m(21)[0m 5 11 1 12 6 13 3 14 7 15
+[4] 0 16 8 17 4 18 9 19 2 20 10 21 5[1m[97m(22)[0m11 1 12 6 13 3 14 7 15
+[5] 0 16 8 17 4 18[1m[97m(19)[0m 2 20 10 21 5 22 11 1 12 6 13 3 14 7 15
+[6] 0 16 8 17 4 18 19 2[1m[97m(24)[0m20 10 21 5 22 11 1 12 6 13 3 14 7 15
+[7] 0 16 8 17 4 18 19 2 24 20[1m[97m(25)[0m10 21 5 22 11 1 12 6 13 3 14 7 15
+
+The goal is to be the [1m[97mplayer with the highest score[0m after the last marble is used up. Assuming the
+example above ends after the marble numbered 25, the winning score is 23+9=[1m[97m32[0m (because player 5 kept
marble 23 and removed marble 9, while no other player got any points in this very short example
game).
Here are a few more examples:
- - 10 players; last marble is worth 1618 points: high score is 8317
+ - 10 players; last marble is worth 1618 points: high score is [1m[97m8317[0m
- - 13 players; last marble is worth 7999 points: high score is 146373
+ - 13 players; last marble is worth 7999 points: high score is [1m[97m146373[0m
- - 17 players; last marble is worth 1104 points: high score is 2764
+ - 17 players; last marble is worth 1104 points: high score is [1m[97m2764[0m
- - 21 players; last marble is worth 6111 points: high score is 54718
+ - 21 players; last marble is worth 6111 points: high score is [1m[97m54718[0m
- - 30 players; last marble is worth 5807 points: high score is 37305
+ - 30 players; last marble is worth 5807 points: high score is [1m[97m37305[0m
-What is the winning Elf's score?
+[1m[97mWhat is the winning Elf's score?[0m
diff --git a/09/part2 b/09/part2
@@ -1,7 +1,15 @@
--- Part Two ---
-Amused by the speed of your answer, the Elves are curious:
+[1m[97mYou now have a complete Intcode computer.[0m
-What would the new winning Elf's score be if the number of the last marble were 100 times larger?
+Finally, you can lock on to the Ceres distress signal! You just need to boost your sensors using the
+BOOST program.
+
+The program runs in sensor boost mode by providing the input instruction the value 2. Once run, it
+will boost the sensors automatically, but it might take a few seconds to complete the operation on
+slower hardware. In sensor boost mode, the program will output a single value: [1m[97mthe coordinates of
+the distress signal[0m.
+
+Run the BOOST program in sensor boost mode. [1m[97mWhat are the coordinates of the distress signal?[0m
diff --git a/10/part1 b/10/part1
@@ -152,9 +152,9 @@ After 4 seconds:
......................
......................
-After 3 seconds, the message appeared briefly: HI. Of course, your message will be much longer and
+After 3 seconds, the message appeared briefly: [1m[97mHI[0m. Of course, your message will be much longer and
will take many more seconds to appear.
-What message will eventually appear in the sky?
+[1m[97mWhat message will eventually appear in the sky?[0m
diff --git a/10/part2 b/10/part2
@@ -1,9 +1,92 @@
--- Part Two ---
-Good thing you didn't have to wait, because that would have taken a long time - much longer than the
-3 seconds in the example above.
+Once you give them the coordinates, the Elves quickly deploy an Instant Monitoring Station to the
+location and discover the worst: there are simply too many asteroids.
-Impressed by your sub-hour communication capabilities, the Elves are curious: exactly how many
-seconds would they have needed to wait for that message to appear?
+The only solution is [1m[97mcomplete vaporization by giant laser[0m.
+
+Fortunately, in addition to an asteroid scanner, the new monitoring station also comes equipped with
+a giant rotating laser perfect for vaporizing asteroids. The laser starts by pointing
+[1m[97mup[0m and always rotates [1m[97mclockwise[0m, vaporizing any asteroid it hits.
+
+If multiple asteroids are [1m[97mexactly[0m in line with the station, the laser only has enough power to
+vaporize [1m[97mone[0m of them before continuing its rotation. In other words, the same asteroids that can be
+[1m[97mdetected[0m can be vaporized, but if vaporizing one asteroid makes another one detectable, the
+newly-detected asteroid won't be vaporized until the laser has returned to the same position by
+rotating a full 360 degrees.
+
+For example, consider the following map, where the asteroid with the new monitoring station (and
+laser) is marked X:
+
+.#....#####...#..
+##...##.#####..##
+##...#...#.#####.
+..#.....X...###..
+..#.#.....#....##
+
+The first nine asteroids to get vaporized, in order, would be:
+
+.#....###[1m[97m2[0m[1m[97m4[0m...#..
+##...##.[1m[97m1[0m[1m[97m3[0m#[1m[97m6[0m[1m[97m7[0m..[1m[97m9[0m#
+##...#...[1m[97m5[0m.[1m[97m8[0m####.
+..#.....X...###..
+..#.#.....#....##
+
+Note that some asteroids (the ones behind the asteroids marked 1, 5, and 7) won't have a chance to
+be vaporized until the next full rotation. The laser continues rotating; the next nine to be
+vaporized are:
+
+.#....###.....#..
+##...##...#.....#
+##...#......[1m[97m1[0m[1m[97m2[0m[1m[97m3[0m[1m[97m4[0m.
+..#.....X...[1m[97m5[0m##..
+..#.[1m[97m9[0m.....[1m[97m8[0m....[1m[97m7[0m[1m[97m6[0m
+
+The next nine to be vaporized are then:
+
+.[1m[97m8[0m....###.....#..
+[1m[97m5[0m[1m[97m6[0m...[1m[97m9[0m#...#.....#
+[1m[97m3[0m[1m[97m4[0m...[1m[97m7[0m...........
+..[1m[97m2[0m.....X....##..
+..[1m[97m1[0m..............
+
+Finally, the laser completes its first full rotation (1 through 3), a second rotation (4 through 8),
+and vaporizes the last asteroid (9) partway through its third rotation:
+
+......[1m[97m2[0m[1m[97m3[0m[1m[97m4[0m.....[1m[97m6[0m..
+......[1m[97m1[0m...[1m[97m5[0m.....[1m[97m7[0m
+.................
+........X....[1m[97m8[0m[1m[97m9[0m..
+.................
+
+In the large example above (the one with the best monitoring station location at 11,13):
+
+
+ - The 1st asteroid to be vaporized is at 11,12.
+
+ - The 2nd asteroid to be vaporized is at 12,1.
+
+ - The 3rd asteroid to be vaporized is at 12,2.
+
+ - The 10th asteroid to be vaporized is at 12,8.
+
+ - The 20th asteroid to be vaporized is at 16,0.
+
+ - The 50th asteroid to be vaporized is at 16,9.
+
+ - The 100th asteroid to be vaporized is at 10,16.
+
+ - The 199th asteroid to be vaporized is at 9,6.
+
+ - [1m[97mThe 200th asteroid to be vaporized is at 8,2.[0m
+
+ - The 201st asteroid to be vaporized is at 10,9.
+
+ - The 299th and final asteroid to be vaporized is at 11,1.
+
+
+The Elves are placing bets on which will be the [1m[97m200th[0m asteroid to be vaporized. Win the bet by
+determining which asteroid that will be; [1m[97mwhat do you get if you multiply its X coordinate by 100 and
+then add its Y coordinate?[0m (For example, 8,2 becomes [1m[97m802[0m.)
diff --git a/11/part1 b/11/part1
@@ -5,50 +5,50 @@ You watch the Elves and their sleigh fade into the distance as they head toward
Actually, you're the one fading. The falling sensation returns.
The low fuel warning light is illuminated on your wrist-mounted device. Tapping it once causes it to
-project a hologram of the situation: a 300x300 grid of fuel cells and their current power levels,
+project a hologram of the situation: a [1m[97m300x300[0m grid of fuel cells and their current power levels,
some negative. You're not sure what negative power means in the context of time travel, but it can't
be good.
-Each fuel cell has a coordinate ranging from 1 to 300 in both the X (horizontal) and Y (vertical)
+Each fuel cell has a coordinate ranging [1m[97mfrom 1 to 300[0m in both the X (horizontal) and Y (vertical)
direction. In X,Y notation, the top-left cell is 1,1, and the top-right cell is 300,1.
-The interface lets you select any 3x3 square of fuel cells. To increase your chances of getting to
-your destination, you decide to choose the 3x3 square with the largest total power.
+The interface lets you select [1m[97many 3x3 square[0m of fuel cells. To increase your chances of getting to
+your destination, you decide to choose the 3x3 square with the [1m[97mlargest total power[0m.
The power level in a given fuel cell can be found through the following process:
- - Find the fuel cell's rack ID, which is its X coordinate plus 10.
+ - Find the fuel cell's [1m[97mrack ID[0m, which is its [1m[97mX coordinate plus 10[0m.
- - Begin with a power level of the rack ID times the Y coordinate.
+ - Begin with a power level of the [1m[97mrack ID[0m times the [1m[97mY coordinate[0m.
- - Increase the power level by the value of the grid serial number (your puzzle input).
+ - Increase the power level by the value of the [1m[97mgrid serial number[0m (your puzzle input).
- - Set the power level to itself multiplied by the rack ID.
+ - Set the power level to itself multiplied by the [1m[97mrack ID[0m.
- - Keep only the hundreds digit of the power level (so 12345 becomes 3; numbers with no hundreds
+ - Keep only the [1m[97mhundreds digit[0m of the power level (so 12[1m[97m3[0m45 becomes 3; numbers with no hundreds
digit become 0).
- - Subtract 5 from the power level.
+ - [1m[97mSubtract 5[0m from the power level.
For example, to find the power level of the fuel cell at 3,5 in a grid with serial number 8:
- - The rack ID is 3 + 10 = 13.
+ - The rack ID is 3 + 10 = [1m[97m13[0m.
- - The power level starts at 13 * 5 = 65.
+ - The power level starts at 13 * 5 = [1m[97m65[0m.
- - Adding the serial number produces 65 + 8 = 73.
+ - Adding the serial number produces 65 + 8 = [1m[97m73[0m.
- - Multiplying by the rack ID produces 73 * 13 = 949.
+ - Multiplying by the rack ID produces 73 * 13 = [1m[97m949[0m.
- - The hundreds digit of 949 is 9.
+ - The hundreds digit of [1m[97m9[0m49 is [1m[97m9[0m.
- - Subtracting 5 produces 9 - 5 = 4.
+ - Subtracting 5 produces 9 - 5 = [1m[97m4[0m.
-So, the power level of this fuel cell is 4.
+So, the power level of this fuel cell is [1m[97m4[0m.
Here are some more example power levels:
@@ -61,27 +61,28 @@ Here are some more example power levels:
Your goal is to find the 3x3 square which has the largest total power. The square must be entirely
-within the 300x300 grid. Identify this square using the X,Y coordinate of its top-left fuel cell.
-For example:
+within the 300x300 grid. Identify this square using the X,Y coordinate of its [1m[97mtop-left fuel
+cell[0m. For example:
-For grid serial number 18, the largest total 3x3 square has a top-left corner of 33,45 (with a total
+For grid serial number 18, the largest total 3x3 square has a top-left corner of [1m[97m33,45[0m (with a total
power of 29); these fuel cells appear in the middle of this 5x5 region:
-2 -4 4 4 4
--4 4 4 4 -5
- 4 3 3 4 -4
- 1 1 2 4 -3
+-4 [1m[97m 4 4 4 [0m-5
+ 4 [1m[97m 3 3 4 [0m-4
+ 1 [1m[97m 1 2 4 [0m-3
-1 0 2 -5 -2
-For grid serial number 42, the largest 3x3 square's top-left is 21,61 (with a total power of 30);
+For grid serial number 42, the largest 3x3 square's top-left is [1m[97m21,61[0m (with a total power of 30);
they are in the middle of this region:
-3 4 2 2 2
--4 4 3 3 4
--5 3 3 4 -4
- 4 3 3 4 -3
+-4 [1m[97m 4 3 3 [0m 4
+-5 [1m[97m 3 3 4 [0m-4
+ 4 [1m[97m 3 3 4 [0m-3
3 3 3 -5 -1
-What is the X,Y coordinate of the top-left fuel cell of the 3x3 square with the largest total power?
+[1m[97mWhat is the X,Y coordinate of the top-left fuel cell of the 3x3 square with the largest total
+power?[0m
diff --git a/11/part2 b/11/part2
@@ -1,22 +1,14 @@
--- Part Two ---
-You discover a dial on the side of the device; it seems to let you select a square of any size, not
-just 3x3. Sizes from 1x1 to 300x300 are supported.
+You're not sure what it's trying to paint, but it's definitely not a [1m[97mregistration identifier[0m. The
+Space Police are getting impatient.
-Realizing this, you now must find the square of any size with the largest total power. Identify this
-square by including its size as a third parameter after the top-left coordinate: a 9x9 square with a
-top-left corner of 3,5 is identified as 3,5,9.
+Checking your external ship cameras again, you notice a white panel marked "emergency hull painting
+robot starting panel". The rest of the panels are [1m[97mstill black[0m, but it looks like the robot was
+expecting to [1m[97mstart on a white panel[0m, not a black one.
-For example:
-
-
- - For grid serial number 18, the largest total square (with a total power of 113) is 16x16 and has
-a top-left corner of 90,269, so its identifier is 90,269,16.
-
- - For grid serial number 42, the largest total square (with a total power of 119) is 12x12 and has
-a top-left corner of 232,251, so its identifier is 232,251,12.
-
-
-What is the X,Y,size identifier of the square with the largest total power?
+Based on the Space Law Space Brochure that the Space Police attached to one of your windows, a valid
+registration identifier is always [1m[97meight capital letters[0m. After starting the robot on a single
+[1m[97mwhite panel[0m instead, [1m[97mwhat registration identifier does it paint[0m on your hull?
diff --git a/12/part1 b/12/part1
@@ -9,12 +9,12 @@ these geothermally-heated caves.
The pots are numbered, with 0 in front of you. To the left, the pots are numbered -1, -2, -3, and
so on; to the right, 1, 2, 3.... Your puzzle input contains a list of pots from 0 to the right and
-whether they do (#) or do not (.) currently contain a plant, the initial state. (No other pots
+whether they do (#) or do not (.) currently contain a plant, the [1m[97minitial state[0m. (No other pots
currently contain plants.) For example, an initial state of #..##.... indicates that pots 0, 3, and
4 currently contain plants.
Your puzzle input also contains some notes you find on a nearby table: someone has been trying to
-figure out how these plants spread to nearby pots. Based on the notes, for each generation of
+figure out how these plants [1m[97mspread[0m to nearby pots. Based on the notes, for each generation of
plants, a given pot has or does not have a plant based on whether that pot (and the two pots on
either side of it) had a plant in the last generation. These are written as LLCRR => N, where L are
pots to the left, C is the current pot being considered, R are the pots to the right, and N is
@@ -33,8 +33,8 @@ the right, but not in the ones immediately to the right and two to the left.
It's not clear what these plants are for, but you're sure it's important, so you'd like to make sure
-the current configuration of plants is sustainable by determining what will happen after 20
-generations.
+the current configuration of plants is sustainable by determining what will happen after [1m[97m20
+generations[0m.
For example, given the following input:
@@ -92,8 +92,8 @@ After one generation, only seven plants remain. The one in pot 0 matched the ru
In this example, after 20 generations, the pots shown as # contain plants, the furthest left of
which is pot -2, and the furthest right of which is pot 34. Adding up all the numbers of
-plant-containing pots after the 20th generation produces 325.
+plant-containing pots after the 20th generation produces [1m[97m325[0m.
-After 20 generations, what is the sum of the numbers of all pots which contain a plant?
+[1m[97mAfter 20 generations, what is the sum of the numbers of all pots which contain a plant?[0m
diff --git a/12/part2 b/12/part2
@@ -1,9 +1,49 @@
--- Part Two ---
-You realize that 20 generations aren't enough. After all, these plants will need to last another
-1500 years to even reach your timeline, not to mention your future.
+All this drifting around in space makes you wonder about the nature of the universe. Does history
+really repeat itself? You're curious whether the moons will ever return to a previous state.
-After fifty billion (50000000000) generations, what is the sum of the numbers of all pots which
-contain a plant?
+Determine [1m[97mthe number of steps[0m that must occur before all of the moons' [1m[97mpositions and velocities[0m
+exactly match a previous point in time.
+
+For example, the first example above takes 2772 steps before they exactly match a previous point in
+time; it eventually returns to the initial state:
+
+After 0 steps:
+pos=<x= -1, y= 0, z= 2>, vel=<x= 0, y= 0, z= 0>
+pos=<x= 2, y=-10, z= -7>, vel=<x= 0, y= 0, z= 0>
+pos=<x= 4, y= -8, z= 8>, vel=<x= 0, y= 0, z= 0>
+pos=<x= 3, y= 5, z= -1>, vel=<x= 0, y= 0, z= 0>
+
+After 2770 steps:
+pos=<x= 2, y= -1, z= 1>, vel=<x= -3, y= 2, z= 2>
+pos=<x= 3, y= -7, z= -4>, vel=<x= 2, y= -5, z= -6>
+pos=<x= 1, y= -7, z= 5>, vel=<x= 0, y= -3, z= 6>
+pos=<x= 2, y= 2, z= 0>, vel=<x= 1, y= 6, z= -2>
+
+After 2771 steps:
+pos=<x= -1, y= 0, z= 2>, vel=<x= -3, y= 1, z= 1>
+pos=<x= 2, y=-10, z= -7>, vel=<x= -1, y= -3, z= -3>
+pos=<x= 4, y= -8, z= 8>, vel=<x= 3, y= -1, z= 3>
+pos=<x= 3, y= 5, z= -1>, vel=<x= 1, y= 3, z= -1>
+
+After 2772 steps:
+pos=<x= -1, y= 0, z= 2>, vel=<x= 0, y= 0, z= 0>
+pos=<x= 2, y=-10, z= -7>, vel=<x= 0, y= 0, z= 0>
+pos=<x= 4, y= -8, z= 8>, vel=<x= 0, y= 0, z= 0>
+pos=<x= 3, y= 5, z= -1>, vel=<x= 0, y= 0, z= 0>
+
+Of course, the universe might last for a [1m[97mvery long time[0m before repeating. Here's a copy of the
+second example from above:
+
+<x=-8, y=-10, z=0>
+<x=5, y=5, z=10>
+<x=2, y=-7, z=3>
+<x=9, y=-8, z=-3>
+
+This set of initial positions takes 4686774924 steps before it repeats a previous state! Clearly,
+you might need to [1m[97mfind a more efficient way to simulate the universe[0m.
+
+[1m[97mHow many steps does it take[0m to reach the first state that exactly matches a previous state?
diff --git a/13/part1 b/13/part1
@@ -1,7 +1,7 @@
--- Day 13: Mine Cart Madness ---
A crop of this size requires significant logistics to transport produce, soil, fertilizer, and so
-on. The Elves are very busy pushing things around in carts on some kind of rudimentary system of
+on. The Elves are very busy pushing things around in [1m[97mcarts[0m on some kind of rudimentary system of
tracks they've come up with.
Seeing as how cart-and-track systems don't appear in recorded history for another 1000 years, the
@@ -30,20 +30,21 @@ intersections:
| |
\-----/
-Several carts are also on the tracks. Carts always face either up (^), down (v), left (<), or right
+Several [1m[97mcarts[0m are also on the tracks. Carts always face either up (^), down (v), left (<), or right
(>). (On your initial map, the track under each cart is a straight path matching the direction the
cart is facing.)
-Each time a cart has the option to turn (by arriving at any intersection), it turns left the first
-time, goes straight the second time, turns right the third time, and then repeats those directions
-starting again with left the fourth time, straight the fifth time, and so on. This process is
-independent of the particular intersection at which the cart has arrived - that is, the cart has no
-per-intersection memory.
+Each time a cart has the option to turn (by arriving at any intersection), it turns
+[1m[97mleft[0m the first time, goes [1m[97mstraight[0m the second time, turns [1m[97mright[0m the third time, and then repeats
+those directions starting again with [1m[97mleft[0m the fourth time, [1m[97mstraight[0m the fifth time, and so on. This
+process is independent of the particular intersection at which the cart has arrived - that is, the
+cart has no per-intersection memory.
Carts all move at the same speed; they take turns moving a single step at a time. They do this based
-on their current location: carts on the top row move first (acting from left to right), then carts
+on their [1m[97mcurrent location[0m: carts on the top row move first (acting from left to right), then carts
on the second row move (again from left to right), then carts on the third row, and so on. Once
-each cart has moved one step, the process repeats; each of these loops is called a tick.
+each cart has moved one step, the process repeats; each of these loops is called a
+[1m[97mtick[0m.
For example, suppose there are two carts on a straight track:
@@ -168,7 +169,7 @@ Here is a longer example:
\------/
After following their respective paths for a while, the carts eventually crash. To help prevent
-crashes, you'd like to know the location of the first crash. Locations are given in X,Y coordinates,
+crashes, you'd like to know [1m[97mthe location of the first crash[0m. Locations are given in X,Y coordinates,
where the furthest left column is X=0 and the furthest top row is Y=0:
111
@@ -180,7 +181,7 @@ where the furthest left column is X=0 and the furthest top row is Y=0:
4\-+-/ \-+--/
5 \------/
-In this example, the location of the first crash is 7,3.
+In this example, the location of the first crash is [1m[97m7,3[0m.
diff --git a/13/part2 b/13/part2
@@ -1,49 +1,26 @@
--- Part Two ---
-There isn't much you can do to prevent crashes in this ridiculous system. However, by predicting the
-crashes, the Elves know where to be in advance and instantly remove the two crashing carts the
-moment any crash occurs.
-
-They can proceed like this for a while, but eventually, they're going to run out of carts. It could
-be useful to figure out where the last cart that hasn't crashed will end up.
-
-For example:
-
-/>-<\
-| |
-| /<+-\
-| | | v
-\>+</ |
- | ^
- \<->/
-
-/---\
-| |
-| v-+-\
-| | | |
-\-+-/ |
- | |
- ^---^
-
-/---\
-| |
-| /-+-\
-| v | |
-\-+-/ |
- ^ ^
- \---/
-
-/---\
-| |
-| /-+-\
-| | | |
-\-+-/ ^
- | |
- \---/
-
-After four very expensive crashes, a tick ends with only one cart remaining; its final location is
-6,4.
-
-What is the location of the last cart at the end of the first tick where it is the only cart left?
+The game didn't run because you didn't put in any quarters. Unfortunately, you did not bring any
+quarters. Memory address 0 represents the number of quarters that have been inserted; set it to 2 to
+play for free.
+
+The arcade cabinet has a joystick that can move left and right. The software reads the position of
+the joystick with input instructions:
+
+
+ - If the joystick is in the [1m[97mneutral position[0m, provide 0.
+
+ - If the joystick is [1m[97mtilted to the left[0m, provide -1.
+
+ - If the joystick is [1m[97mtilted to the right[0m, provide 1.
+
+
+The arcade cabinet also has a segment display capable of showing a single number that represents the
+player's current score. When three output instructions specify X=-1, Y=0, the third output
+instruction is not a tile; the value instead specifies the new score to show in the segment display.
+ For example, a sequence of output values like -1,0,12345 would show 12345 as the player's current
+score.
+
+Beat the game by breaking all the blocks. [1m[97mWhat is your score after the last block is broken?[0m
diff --git a/14/part1 b/14/part1
@@ -1,19 +1,19 @@
--- Day 14: Chocolate Charts ---
You finally have a chance to look at all of the produce moving around. Chocolate, cinnamon, mint,
-chili peppers, nutmeg, vanilla... the Elves must be growing these plants to make hot chocolate! As
+chili peppers, nutmeg, vanilla... the Elves must be growing these plants to make [1m[97mhot chocolate[0m! As
you realize this, you hear a conversation in the distance. When you go to investigate, you discover
two Elves in what appears to be a makeshift underground kitchen/laboratory.
The Elves are trying to come up with the ultimate hot chocolate recipe; they're even maintaining a
-scoreboard which tracks the quality score (0-9) of each recipe.
+scoreboard which tracks the quality [1m[97mscore[0m (0-9) of each recipe.
Only two recipes are on the board: the first recipe got a score of 3, the second, 7. Each of the two
-Elves has a current recipe: the first Elf starts with the first recipe, and the second Elf starts
+Elves has a [1m[97mcurrent recipe[0m: the first Elf starts with the first recipe, and the second Elf starts
with the second recipe.
To create new recipes, the two Elves combine their current recipes. This creates new recipes from
-the digits of the sum of the current recipes' scores. With the current recipes' scores of 3 and 7,
+the [1m[97mdigits of the sum[0m of the current recipes' scores. With the current recipes' scores of 3 and 7,
their sum is 10, and so two new recipes would be created: the first with score 1 and the second with
score 0. If the current recipes' scores were 2 and 3, the sum, 5, would only create one recipe (with
a score of 5) with its single digit.
@@ -22,8 +22,8 @@ The new recipes are added to the end of the scoreboard in the order they are cre
first round, the scoreboard is 3, 7, 1, 0.
After all new recipes are added to the scoreboard, each Elf picks a new current recipe. To do this,
-the Elf steps forward through the scoreboard a number of recipes equal to 1 plus the score of their
-current recipe. So, after the first round, the first Elf moves forward 1 + 3 = 4 times, while the
+the Elf steps forward through the scoreboard a number of recipes equal to [1m[97m1 plus the score of their
+current recipe[0m. So, after the first round, the first Elf moves forward 1 + 3 = 4 times, while the
second Elf moves forward 1 + 7 = 8 times. If they run out of recipes, they loop back around to the
beginning. After the first round, both Elves happen to loop around until they land on the same
recipe that they had in the beginning; in general, they will move to different recipes.
@@ -46,15 +46,15 @@ process:
3 7 1 0 1 0 1 2 4 5 [1] 5 8 9 1 (6) 7
3 7 1 0 (1) 0 1 2 4 5 1 5 [8] 9 1 6 7 7
3 7 [1] 0 1 0 (1) 2 4 5 1 5 8 9 1 6 7 7 9
- 3 7 1 0 [1] 0 1 2 (4) 5 1 5 8 9 1 6 7 7 9 2
+ 3 7 1 0 [1] 0 1 2 (4) [1m[97m5 1 5 8 9 1 6 7 7 9[0m 2
The Elves think their skill will improve after making a few recipes (your puzzle input). However,
-that could take ages; you can speed this up considerably by identifying the scores of the ten
-recipes after that. For example:
+that could take ages; you can speed this up considerably by identifying [1m[97mthe scores of the ten
+recipes[0m after that. For example:
- If the Elves think their skill will improve after making 9 recipes, the scores of the ten recipes
-after the first nine on the scoreboard would be 5158916779 (highlighted in the last line of the
+[1m[97mafter[0m the first nine on the scoreboard would be 5158916779 (highlighted in the last line of the
diagram).
- After 5 recipes, the scores of the next ten would be 0124515891.
@@ -64,6 +64,7 @@ diagram).
- After 2018 recipes, the scores of the next ten would be 5941429882.
-What are the scores of the ten recipes immediately after the number of recipes in your puzzle input?
+[1m[97mWhat are the scores of the ten recipes immediately after the number of recipes in your puzzle
+input?[0m
diff --git a/14/part2 b/14/part2
@@ -1,19 +1,18 @@
--- Part Two ---
-As it turns out, you got the Elves' plan backwards. They actually want to know how many recipes
-appear on the scoreboard to the left of the first recipes whose scores are the digits from your
-puzzle input.
+After collecting ORE for a while, you check your cargo hold: [1m[97m1 trillion[0m ([1m[97m1000000000000[0m) units of
+ORE.
+[1m[97mWith that much ore[0m, given the examples above:
- - 51589 first appears after 9 recipes.
- - 01245 first appears after 5 recipes.
+ - The 13312 ORE-per-FUEL example could produce [1m[97m82892753[0m FUEL.
- - 92510 first appears after 18 recipes.
+ - The 180697 ORE-per-FUEL example could produce [1m[97m5586022[0m FUEL.
- - 59414 first appears after 2018 recipes.
+ - The 2210736 ORE-per-FUEL example could produce [1m[97m460664[0m FUEL.
-How many recipes appear on the scoreboard to the left of the score sequence in your puzzle input?
+Given 1 trillion ORE, [1m[97mwhat is the maximum amount of FUEL you can produce?[0m
diff --git a/15/part1 b/15/part1
@@ -6,14 +6,14 @@ caves will do anything to steal it. Looks like they're here for a fight.
You scan the area, generating a map of the walls (#), open cavern (.), and starting position of
every Goblin (G) and Elf (E) (your puzzle input).
-Combat proceeds in rounds; in each round, each unit that is still alive takes a turn, resolving all
-of its actions before the next unit's turn begins. On each unit's turn, it tries to move into range
-of an enemy (if it isn't already) and then attack (if it is in range).
+Combat proceeds in [1m[97mrounds[0m; in each round, each unit that is still alive takes a [1m[97mturn[0m, resolving all
+of its actions before the next unit's turn begins. On each unit's turn, it tries to
+[1m[97mmove[0m into range of an enemy (if it isn't already) and then [1m[97mattack[0m (if it is in range).
All units are very disciplined and always follow very strict combat rules. Units never move or
attack diagonally, as doing so would be dishonorable. When multiple choices are equally valid, ties
-are broken in reading order: top-to-bottom, then left-to-right. For instance, the order in which
-units take their turns within a round is the reading order of their starting positions in that
+are broken in [1m[97mreading order[0m: top-to-bottom, then left-to-right. For instance, the order in which
+units take their turns within a round is the [1m[97mreading order of their starting positions[0m in that
round, regardless of the type of unit or whether other units have moved after the round started.
For example:
@@ -25,25 +25,25 @@ These units: turns in this order:
#.G.E.# #.6.7.#
####### #######
-Each unit begins its turn by identifying all possible targets (enemy units). If no targets remain,
+Each unit begins its turn by identifying all possible [1m[97mtargets[0m (enemy units). If no targets remain,
combat ends.
-Then, the unit identifies all of the open squares (.) that are in range of each target; these are
-the squares which are adjacent (immediately up, down, left, or right) to any target and which aren't
-already occupied by a wall or another unit. Alternatively, the unit might already be in range of a
+Then, the unit identifies all of the open squares (.) that are [1m[97min range[0m of each target; these are
+the squares which are [1m[97madjacent[0m (immediately up, down, left, or right) to any target and which aren't
+already occupied by a wall or another unit. Alternatively, the unit might [1m[97malready[0m be in range of a
target. If the unit is not already in range of a target, and there are no open squares which are in
range of a target, the unit ends its turn.
-If the unit is already in range of a target, it does not move, but continues its turn with an
-attack. Otherwise, since it is not in range of a target, it moves.
+If the unit is already in range of a target, it does not [1m[97mmove[0m, but continues its turn with an
+[1m[97mattack[0m. Otherwise, since it is not in range of a target, it [1m[97mmoves[0m.
-To move, the unit first considers the squares that are in range and determines which of those
-squares it could reach in the fewest steps. A step is a single movement to any adjacent (immediately
+To [1m[97mmove[0m, the unit first considers the squares that are [1m[97min range[0m and determines [1m[97mwhich of those
+squares it could reach in the fewest steps[0m. A [1m[97mstep[0m is a single movement to any [1m[97madjacent[0m (immediately
up, down, left, or right) open (.) square. Units cannot move into walls or other units. The unit
-does this while considering the current positions of units and does not do any prediction about
+does this while considering the [1m[97mcurrent positions of units[0m and does [1m[97mnot[0m do any prediction about
where units will be later. If the unit cannot reach (find an open path to) any of the squares that
-are in range, it ends its turn. If multiple squares are in range and tied for being reachable in the
-fewest steps, the square which is first in reading order is chosen. For example:
+are in range, it ends its turn. If multiple squares are in range and [1m[97mtied[0m for being reachable in the
+fewest steps, the square which is first in [1m[97mreading order[0m is chosen. For example:
Targets: In range: Reachable: Nearest: Chosen:
####### ####### ####### ####### #######
@@ -55,26 +55,26 @@ Targets: In range: Reachable: Nearest: Chosen:
In the above scenario, the Elf has three targets (the three Goblins):
- - Each of the Goblins has open, adjacent squares which are in range (marked with a ? on the map).
+ - Each of the Goblins has open, adjacent squares which are [1m[97min range[0m (marked with a ? on the map).
- - Of those squares, four are reachable (marked @); the other two (on the right) would require
+ - Of those squares, four are [1m[97mreachable[0m (marked @); the other two (on the right) would require
moving through a wall or unit to reach.
- - Three of these reachable squares are nearest, requiring the fewest steps (only 2) to reach
+ - Three of these reachable squares are [1m[97mnearest[0m, requiring the fewest steps (only 2) to reach
(marked !).
- - Of those, the square which is first in reading order is chosen (+).
+ - Of those, the square which is first in reading order is [1m[97mchosen[0m (+).
-The unit then takes a single step toward the chosen square along the shortest path to that square.
+The unit then takes a single [1m[97mstep[0m toward the chosen square along the [1m[97mshortest path[0m to that square.
If multiple steps would put the unit equally closer to its destination, the unit chooses the step
-which is first in reading order. (This requires knowing when there is more than one shortest path so
-that you can consider the first step of each such path.) For example:
+which is first in reading order. (This requires knowing when there is [1m[97mmore than one shortest
+path[0m so that you can consider the first step of each such path.) For example:
In range: Nearest: Chosen: Distance: Step:
####### ####### ####### ####### #######
-#.E...# #.E...# #.E...# #4E212# #..E..#
-#...?.# --> #...!.# --> #...+.# --> #32101# --> #.....#
+#.E...# #.E...# #.E...# #4E[1m[97m2[0m12# #..E..#
+#...?.# --> #...!.# --> #...+.# --> #3[1m[97m2[0m101# --> #.....#
#..?G?# #..!G.# #...G.# #432G2# #...G.#
####### ####### ####### ####### #######
@@ -82,7 +82,7 @@ The Elf sees three squares in range of a target (?), two of which are nearest (!
in reading order is chosen (+). Under "Distance", each open square is marked with its distance from
the destination square; the two squares to which the Elf could move on this turn (down and to the
right) are both equally good moves and would leave the Elf 2 steps from being in range of the
-Goblin. Because the step which is first in reading order is chosen, the Elf moves right one square.
+Goblin. Because the step which is first in reading order is chosen, the Elf moves [1m[97mright[0m one square.
Here's a larger example of movement:
@@ -133,25 +133,25 @@ After 3 rounds:
Once the Goblins and Elf reach the positions above, they all are either in range of a target or
cannot find any square in range of a target, and so none of the units can move until a unit dies.
-After moving (or if the unit began its turn in range of a target), the unit attacks.
+After moving (or if the unit began its turn in range of a target), the unit [1m[97mattacks[0m.
-To attack, the unit first determines all of the targets that are in range of it by being immediately
-adjacent to it. If there are no such targets, the unit ends its turn. Otherwise, the adjacent target
-with the fewest hit points is selected; in a tie, the adjacent target with the fewest hit points
+To [1m[97mattack[0m, the unit first determines [1m[97mall[0m of the targets that are [1m[97min range[0m of it by being immediately
+[1m[97madjacent[0m to it. If there are no such targets, the unit ends its turn. Otherwise, the adjacent target
+with the [1m[97mfewest hit points[0m is selected; in a tie, the adjacent target with the fewest hit points
which is first in reading order is selected.
-The unit deals damage equal to its attack power to the selected target, reducing its hit points by
-that amount. If this reduces its hit points to 0 or fewer, the selected target dies: its square
+The unit deals damage equal to its [1m[97mattack power[0m to the selected target, reducing its hit points by
+that amount. If this reduces its hit points to 0 or fewer, the selected target [1m[97mdies[0m: its square
becomes . and it takes no further turns.
-Each unit, either Goblin or Elf, has 3 attack power and starts with 200 hit points.
+Each [1m[97munit[0m, either Goblin or Elf, has 3 [1m[97mattack power[0m and starts with 200 [1m[97mhit points[0m.
For example, suppose the only Elf is about to attack:
HP: HP:
G.... 9 G.... 9
..G.. 4 ..G.. 4
-..EG. 2 --> ..E..
+..E[1m[97mG[0m. 2 --> ..E..
..G.. 2 ..G.. 2
...G. 1 ...G. 1
@@ -167,10 +167,10 @@ After attacking, the unit's turn ends. Regardless of how the unit's turn ends,
round takes its turn. If all units have taken turns in this round, the round ends, and a new round
begins.
-The Elves look quite outnumbered. You need to determine the outcome of the battle: the number of
-full rounds that were completed (not counting the round in which combat ends) multiplied by the sum
-of the hit points of all remaining units at the moment combat ends. (Combat only ends when a unit
-finds no targets during its turn.)
+The Elves look quite outnumbered. You need to determine the [1m[97moutcome[0m of the battle: the
+[1m[97mnumber of full rounds that were completed[0m (not counting the round in which combat ends) multiplied
+by [1m[97mthe sum of the hit points of all remaining units[0m at the moment combat ends. (Combat only ends
+when a unit finds no targets during its turn.)
Below is an entire sample combat. Next to each map, each row's units' hit points are listed from
left to right.
@@ -270,9 +270,9 @@ After 47 rounds:
#######
Before the 48th round can finish, the top-left Goblin finds that there are no targets remaining, and
-so combat ends. So, the number of full rounds that were completed is 47, and the sum of the hit
-points of all remaining units is 200+131+59+200 = 590. From these, the outcome of the battle is 47 *
-590 = 27730.
+so combat ends. So, the number of [1m[97mfull rounds[0m that were completed is [1m[97m47[0m, and the sum of the hit
+points of all remaining units is 200+131+59+200 = [1m[97m590[0m. From these, the [1m[97moutcome[0m of the battle is 47 *
+590 = [1m[97m27730[0m.
Here are a few example summarized combats:
@@ -286,7 +286,7 @@ Here are a few example summarized combats:
Combat ends after 37 full rounds
Elves win with 982 total hit points left
-Outcome: 37 * 982 = 36334
+Outcome: 37 * 982 = [1m[97m36334[0m
####### #######
#E..EG# #.E.E.# E(164), E(197)
@@ -298,7 +298,7 @@ Outcome: 37 * 982 = 36334
Combat ends after 46 full rounds
Elves win with 859 total hit points left
-Outcome: 46 * 859 = 39514
+Outcome: 46 * 859 = [1m[97m39514[0m
####### #######
#E.G#.# #G.G#.# G(200), G(98)
@@ -310,7 +310,7 @@ Outcome: 46 * 859 = 39514
Combat ends after 35 full rounds
Goblins win with 793 total hit points left
-Outcome: 35 * 793 = 27755
+Outcome: 35 * 793 = [1m[97m27755[0m
####### #######
#.E...# #.....#
@@ -322,7 +322,7 @@ Outcome: 35 * 793 = 27755
Combat ends after 54 full rounds
Goblins win with 536 total hit points left
-Outcome: 54 * 536 = 28944
+Outcome: 54 * 536 = [1m[97m28944[0m
######### #########
#G......# #.G.....# G(137)
@@ -336,8 +336,8 @@ Outcome: 54 * 536 = 28944
Combat ends after 20 full rounds
Goblins win with 937 total hit points left
-Outcome: 20 * 937 = 18740
+Outcome: 20 * 937 = [1m[97m18740[0m
-What is the outcome of the combat described in your puzzle input?
+[1m[97mWhat is the outcome[0m of the combat described in your puzzle input?
diff --git a/15/part2 b/15/part2
@@ -1,91 +1,57 @@
--- Part Two ---
-According to your calculations, the Elves are going to lose badly. Surely, you won't mess up the
-timeline too much if you give them just a little advanced technology, right?
-
-You need to make sure the Elves not only win, but also suffer no losses: even the death of a single
-Elf is unacceptable.
-
-However, you can't go too far: larger changes will be more likely to permanently alter spacetime.
-
-So, you need to find the outcome of the battle in which the Elves have the lowest integer attack
-power (at least 4) that allows them to win without a single death. The Goblins always have an attack
-power of 3.
-
-In the first summarized example above, the lowest attack power the Elves need to win without losses
-is 15:
-
-####### #######
-#.G...# #..E..# E(158)
-#...EG# #...E.# E(14)
-#.#.#G# --> #.#.#.#
-#..G#E# #...#.#
-#.....# #.....#
-####### #######
-
-Combat ends after 29 full rounds
-Elves win with 172 total hit points left
-Outcome: 29 * 172 = 4988
-
-In the second example above, the Elves need only 4 attack power:
-
-####### #######
-#E..EG# #.E.E.# E(200), E(23)
-#.#G.E# #.#E..# E(200)
-#E.##E# --> #E.##E# E(125), E(200)
-#G..#.# #.E.#.# E(200)
-#..E#.# #...#.#
-####### #######
-
-Combat ends after 33 full rounds
-Elves win with 948 total hit points left
-Outcome: 33 * 948 = 31284
-
-In the third example above, the Elves need 15 attack power:
-
-####### #######
-#E.G#.# #.E.#.# E(8)
-#.#G..# #.#E..# E(86)
-#G.#.G# --> #..#..#
-#G..#.# #...#.#
-#...E.# #.....#
-####### #######
-
-Combat ends after 37 full rounds
-Elves win with 94 total hit points left
-Outcome: 37 * 94 = 3478
-
-In the fourth example above, the Elves need 12 attack power:
-
-####### #######
-#.E...# #...E.# E(14)
-#.#..G# #.#..E# E(152)
-#.###.# --> #.###.#
-#E#G#G# #.#.#.#
-#...#G# #...#.#
-####### #######
-
-Combat ends after 39 full rounds
-Elves win with 166 total hit points left
-Outcome: 39 * 166 = 6474
-
-In the last example above, the lone Elf needs 34 attack power:
-
-######### #########
-#G......# #.......#
-#.E.#...# #.E.#...# E(38)
-#..##..G# #..##...#
-#...##..# --> #...##..#
-#...#...# #...#...#
-#.G...G.# #.......#
-#.....G.# #.......#
-######### #########
-
-Combat ends after 30 full rounds
-Elves win with 38 total hit points left
-Outcome: 30 * 38 = 1140
-
-After increasing the Elves' attack power until it is just barely enough for them to win without any
-Elves dying, what is the outcome of the combat described in your puzzle input?
+You quickly repair the oxygen system; oxygen gradually fills the area.
+
+Oxygen starts in the location containing the repaired oxygen system. It takes [1m[97mone minute[0m for oxygen
+to spread to all open locations that are adjacent to a location that already contains oxygen.
+Diagonal locations are [1m[97mnot[0m adjacent.
+
+In the example above, suppose you've used the droid to explore the area fully and have the following
+map (where locations that currently contain oxygen are marked O):
+
+ ##
+#..##
+#.#..#
+#.O.#
+ ###
+
+Initially, the only location which contains oxygen is the location of the repaired oxygen system.
+However, after one minute, the oxygen spreads to all open (.) locations that are adjacent to a
+location containing oxygen:
+
+ ##
+#..##
+#.#..#
+#OOO#
+ ###
+
+After a total of two minutes, the map looks like this:
+
+ ##
+#..##
+#O#O.#
+#OOO#
+ ###
+
+After a total of three minutes:
+
+ ##
+#O.##
+#O#OO#
+#OOO#
+ ###
+
+And finally, the whole region is full of oxygen after a total of four minutes:
+
+ ##
+#OO##
+#O#OO#
+#OOO#
+ ###
+
+So, in this example, all locations contain oxygen after [1m[97m4[0m minutes.
+
+Use the repair droid to get a complete map of the area. [1m[97mHow many minutes will it take to fill with
+oxygen?[0m
diff --git a/16/part1 b/16/part1
@@ -10,13 +10,13 @@ and error, you manage to pull up a programming manual on the device's tiny scree
According to the manual, the device has four registers (numbered 0 through 3) that can be
manipulated by instructions containing one of 16 opcodes. The registers start with the value 0.
-Every instruction consists of four values: an opcode, two inputs (named A and B), and an output
-(named C), in that order. The opcode specifies the behavior of the instruction and how the inputs
-are interpreted. The output, C, is always treated as a register.
+Every instruction consists of four values: an [1m[97mopcode[0m, two [1m[97minputs[0m (named A and B), and an
+[1m[97moutput[0m (named C), in that order. The opcode specifies the behavior of the instruction and how the
+inputs are interpreted. The output, C, is always treated as a register.
-In the opcode descriptions below, if something says "value A", it means to take the number given as
-A literally. (This is also called an "immediate" value.) If something says "register A", it means to
-use the number given as A to read from (or write to) the register with that number. So, if the
+In the opcode descriptions below, if something says "[1m[97mvalue A[0m", it means to take the number given as
+A [1m[97mliterally[0m. (This is also called an "immediate" value.) If something says "[1m[97mregister A[0m", it means to
+use the number given as A to read from (or write to) the [1m[97mregister with that number[0m. So, if the
opcode addi adds register A and value B, storing the result in register C, and the instruction addi
0 7 3 is encountered, it would add 7 to the value contained by register 0 and store the sum in
register 3, never modifying registers 0, 1, or 2 in the process.
@@ -96,8 +96,8 @@ Otherwise, register C is set to 0.
Otherwise, register C is set to 0.
-Unfortunately, while the manual gives the name of each opcode, it doesn't seem to indicate the
-number. However, you can monitor the CPU to see the contents of the registers before and after
+Unfortunately, while the manual gives the [1m[97mname[0m of each opcode, it doesn't seem to indicate the
+[1m[97mnumber[0m. However, you can monitor the CPU to see the contents of the registers before and after
instructions are executed to try to work them out. Each opcode has a number from 0 through 15, but
the manual doesn't say which is which. For example, suppose you capture the following sample:
@@ -125,12 +125,12 @@ number given for B is irrelevant.
None of the other opcodes produce the result captured in the sample. Because of this, the sample
-above behaves like three opcodes.
+above [1m[97mbehaves like three opcodes[0m.
You collect many of these samples (the first section of your puzzle input). The manual also includes
-a small test program (the second section of your puzzle input) - you can ignore it for now.
+a small test program (the second section of your puzzle input) - you can [1m[97mignore it for now[0m.
-Ignoring the opcode numbers, how many samples in your puzzle input behave like three or more
-opcodes?
+Ignoring the opcode numbers, [1m[97mhow many samples in your puzzle input behave like three or more
+opcodes?[0m
diff --git a/16/part2 b/16/part2
@@ -1,8 +1,32 @@
--- Part Two ---
-Using the samples you collected, work out the number of each opcode and execute the test program
-(the second section of your puzzle input).
+Now that your FFT is working, you can decode the [1m[97mreal signal[0m.
-What value is contained in register 0 after executing the test program?
+The real signal is your puzzle input [1m[97mrepeated 10000 times[0m. Treat this new signal as a single input
+list. Patterns are still calculated as before, and 100 phases of FFT are still applied.
+
+The [1m[97mfirst seven digits[0m of your initial input signal also represent the [1m[97mmessage offset[0m. The message
+offset is the location of the eight-digit message in the final output list. Specifically, the
+message offset indicates [1m[97mthe number of digits to skip[0m before reading the eight-digit message. For
+example, if the first seven digits of your initial input signal were 1234567, the eight-digit
+message would be the eight digits after skipping 1,234,567 digits of the final output list. Or, if
+the message offset were 7 and your final output list were 98765432109876543210, the eight-digit
+message would be 21098765. (Of course, your real message offset will be a seven-digit number, not a
+one-digit number like 7.)
+
+Here is the eight-digit message in the final output list after 100 phases. The message offset given
+in each input has been highlighted. (Note that the inputs given below are repeated 10000 times to
+find the actual starting input lists.)
+
+
+ - [1m[97m0303673[0m2577212944063491565474664 becomes 84462026.
+
+ - [1m[97m0293510[0m9699940807407585447034323 becomes 78725270.
+
+ - [1m[97m0308177[0m0884921959731165446850517 becomes 53553731.
+
+
+After repeating your input signal 10000 times and running 100 phases of FFT, [1m[97mwhat is the eight-digit
+message embedded in the final output list?[0m
diff --git a/17/part1 b/17/part1
@@ -3,15 +3,15 @@
You arrive in the year 18. If it weren't for the coat you got in 1018, you would be very cold: the
North Pole base hasn't even been constructed.
-Rather, it hasn't been constructed yet. The Elves are making a little progress, but there's not a
+Rather, it hasn't been constructed [1m[97myet[0m. The Elves are making a little progress, but there's not a
lot of liquid water in this climate, so they're getting very dehydrated. Maybe there's more
underground?
-You scan a two-dimensional vertical slice of the ground nearby and discover that it is mostly sand
-with veins of clay. The scan only provides data with a granularity of square meters, but it should
-be good enough to determine how much water is trapped there. In the scan, x represents the distance
-to the right, and y represents the distance down. There is also a spring of water near the surface
-at x=500, y=0. The scan identifies which square meters are clay (your puzzle input).
+You scan a two-dimensional vertical slice of the ground nearby and discover that it is mostly
+[1m[97msand[0m with veins of [1m[97mclay[0m. The scan only provides data with a granularity of [1m[97msquare meters[0m, but it
+should be good enough to determine how much water is trapped there. In the scan, x represents the
+distance to the right, and y represents the distance down. There is also a [1m[97mspring of water[0m near the
+surface at x=500, y=0. The scan identifies [1m[97mwhich square meters are clay[0m (your puzzle input).
For example, suppose your scan shows the following veins of clay:
@@ -45,8 +45,8 @@ increasing downward, this becomes:
12 ....#.....#...
13 ....#######...
-The spring of water will produce water forever. Water can move through sand, but is blocked by clay.
-Water always moves down when possible, and spreads to the left and right otherwise, filling space
+The spring of water will produce water [1m[97mforever[0m. Water can move through sand, but is blocked by clay.
+Water [1m[97malways moves down[0m when possible, and spreads to the left and right otherwise, filling space
that has clay on both sides and falling out otherwise.
For example, if five squares of water are created, they will flow downward until they reach the clay
@@ -109,7 +109,7 @@ water, it cannot settle there, and so the next five squares of water settle like
......+.......
......|.....#.
-.#..#||||...#.
+.#..#[1m[97m|[0m|||...#.
.#..#~~#|.....
.#..#~~#|.....
.#~~~~~#|.....
@@ -163,15 +163,15 @@ overflowing beyond the bottom of the scanned data:
...|.......|.. (line not counted: below maximum y value)
...|.......|.. (line not counted: below maximum y value)
-How many tiles can be reached by the water? To prevent counting forever, ignore tiles with a y
+How many tiles can be reached by the water? [1m[97mTo prevent counting forever[0m, ignore tiles with a y
coordinate smaller than the smallest y coordinate in your scan data or larger than the largest one.
Any x coordinate is valid. In this example, the lowest y coordinate given is 1, and the highest is
13, causing the water spring (in row 0) and the water falling off the bottom of the render (in rows
14 through infinity) to be ignored.
So, in the example above, counting both water at rest (~) and other sand tiles the water can
-hypothetically reach (|), the total number of tiles the water can reach is 57.
+hypothetically reach (|), the total number of tiles the water can reach is [1m[97m57[0m.
-How many tiles can the water reach within the range of y values in your scan?
+[1m[97mHow many tiles can the water reach[0m within the range of y values in your scan?
diff --git a/17/part2 b/17/part2
@@ -1,10 +1,105 @@
--- Part Two ---
-After a very long time, the water spring will run dry. How much water will be retained?
+Now for the tricky part: notifying all the other robots about the solar flare. The vacuum robot can
+do this automatically if it gets into range of a robot. However, you can't see the other robots on
+the camera, so you need to be thorough instead: you need to make the vacuum robot [1m[97mvisit every part
+of the scaffold at least once[0m.
-In the example above, water that won't eventually drain out is shown as ~, a total of 29 tiles.
+The vacuum robot normally wanders randomly, but there isn't time for that today. Instead, you can
+[1m[97moverride its movement logic[0m with new rules.
-How many water tiles are left after the water spring stops producing water and all remaining water
-not at rest has drained?
+Force the vacuum robot to wake up by changing the value in your ASCII program at address 0 from 1 to
+[1m[97m2[0m. When you do this, you will be automatically prompted for the new movement rules that the vacuum
+robot should use. The ASCII program will use input instructions to receive them, but they need to be
+provided as ASCII code; end each line of logic with a single newline, ASCII code 10.
+
+First, you will be prompted for the [1m[97mmain movement routine[0m. The main routine may only call the
+[1m[97mmovement functions[0m: A, B, or C. Supply the movement functions to use as ASCII text, separating them
+with commas (,, ASCII code 44), and ending the list with a newline (ASCII code 10). For example, to
+call A twice, then alternate between B and C three times, provide the string A,A,B,C,B,C,B,C and
+then a newline.
+
+Then, you will be prompted for each [1m[97mmovement function[0m. Movement functions may use L to [1m[97mturn
+left[0m, R to [1m[97mturn right[0m, or a number to [1m[97mmove forward[0m that many units. Movement functions may not call
+other movement functions. Again, separate the actions with commas and end the list with a newline.
+For example, to move forward 10 units, turn left, move forward 8 units, turn right, and finally move
+forward 6 units, provide the string 10,L,8,R,6 and then a newline.
+
+Finally, you will be asked whether you want to see a [1m[97mcontinuous video feed[0m; provide either y or n
+and a newline. Enabling the continuous video feed can help you see what's going on, but it also
+requires a significant amount of processing power, and may even cause your Intcode computer to
+overheat.
+
+Due to the limited amount of memory in the vacuum robot, the ASCII definitions of the main routine
+and the movement functions may each contain [1m[97mat most 20 characters[0m, not counting the newline.
+
+For example, consider the following camera feed:
+
+#######...#####
+#.....#...#...#
+#.....#...#...#
+......#...#...#
+......#...###.#
+......#.....#.#
+^########...#.#
+......#.#...#.#
+......#########
+........#...#..
+....#########..
+....#...#......
+....#...#......
+....#...#......
+....#####......
+
+In order for the vacuum robot to [1m[97mvisit every part of the scaffold at least once[0m, one path it could
+take is:
+
+R,8,R,8,R,4,R,4,R,8,L,6,L,2,R,4,R,4,R,8,R,8,R,8,L,6,L,2
+Without the memory limit, you could just supply this whole string to function A and have the main
+routine call A once. However, you'll need to split it into smaller parts.
+
+One approach is:
+
+
+ - [1m[97mMain routine: A,B,C,B,A,C[0m(ASCII input: 65, 44, 66, 44, 67, 44, 66, 44, 65, 44, 67, 10)
+
+ - [1m[97mFunction A: R,8,R,8[0m(ASCII input: 82, 44, 56, 44, 82, 44, 56, 10)
+
+ - [1m[97mFunction B: R,4,R,4,R,8[0m(ASCII input: 82, 44, 52, 44, 82, 44, 52, 44, 82, 44, 56, 10)
+
+ - [1m[97mFunction C: L,6,L,2[0m(ASCII input: 76, 44, 54, 44, 76, 44, 50, 10)
+
+
+Visually, this would break the desired path into the following parts:
+
+A, B, C, B, A, C
+R,8,R,8, R,4,R,4,R,8, L,6,L,2, R,4,R,4,R,8, R,8,R,8, L,6,L,2
+
+CCCCCCA...BBBBB
+C.....A...B...B
+C.....A...B...B
+......A...B...B
+......A...CCC.B
+......A.....C.B
+^AAAAAAAA...C.B
+......A.A...C.B
+......AAAAAA#AB
+........A...C..
+....BBBB#BBBB..
+....B...A......
+....B...A......
+....B...A......
+....BBBBA......
+
+Of course, the scaffolding outside your ship is much more complex.
+
+As the vacuum robot finds other robots and notifies them of the impending solar flare, it also can't
+help but leave them squeaky clean, collecting any space dust it finds. Once it finishes the
+programmed set of movements, assuming it hasn't drifted off into space, the cleaning robot will
+return to its docking station and report the amount of space dust it collected as a large, non-ASCII
+value in a single output instruction.
+
+After visiting every part of the scaffold at least once, [1m[97mhow much dust does the vacuum robot report
+it has collected?[0m
diff --git a/18/part1 b/18/part1
@@ -2,32 +2,32 @@
On the outskirts of the North Pole base construction project, many Elves are collecting lumber.
-The lumber collection area is 50 acres by 50 acres; each acre can be either open ground (.), trees
-(|), or a lumberyard (#). You take a scan of the area (your puzzle input).
+The lumber collection area is 50 acres by 50 acres; each acre can be either [1m[97mopen ground[0m (.),
+[1m[97mtrees[0m (|), or a [1m[97mlumberyard[0m (#). You take a scan of the area (your puzzle input).
-Strange magic is at work here: each minute, the landscape looks entirely different. In exactly one
-minute, an open acre can fill with trees, a wooded acre can be converted to a lumberyard, or a
+Strange magic is at work here: each minute, the landscape looks entirely different. In exactly
+[1m[97mone minute[0m, an open acre can fill with trees, a wooded acre can be converted to a lumberyard, or a
lumberyard can be cleared to open ground (the lumber having been sent to other projects).
-The change to each acre is based entirely on the contents of that acre as well as the number of
-open, wooded, or lumberyard acres adjacent to it at the start of each minute. Here, "adjacent" means
+The change to each acre is based entirely on [1m[97mthe contents of that acre[0m as well as [1m[97mthe number of
+open, wooded, or lumberyard acres adjacent to it[0m at the start of each minute. Here, "adjacent" means
any of the eight acres surrounding that acre. (Acres on the edges of the lumber collection area
might have fewer than eight adjacent acres; the missing acres aren't counted.)
In particular:
- - An open acre will become filled with trees if three or more adjacent acres contained trees.
+ - An [1m[97mopen[0m acre will become filled with [1m[97mtrees[0m if [1m[97mthree or more[0m adjacent acres contained trees.
Otherwise, nothing happens.
- - An acre filled with trees will become a lumberyard if three or more adjacent acres were
+ - An acre filled with [1m[97mtrees[0m will become a [1m[97mlumberyard[0m if [1m[97mthree or more[0m adjacent acres were
lumberyards. Otherwise, nothing happens.
- - An acre containing a lumberyard will remain a lumberyard if it was adjacent to at least one other
-lumberyard and at least one acre containing trees. Otherwise, it becomes open.
+ - An acre containing a [1m[97mlumberyard[0m will remain a [1m[97mlumberyard[0m if it was adjacent to [1m[97mat least one other
+lumberyard and at least one acre containing trees[0m. Otherwise, it becomes [1m[97mopen[0m.
-These changes happen across all acres simultaneously, each of them using the state of all acres at
+These changes happen across all acres [1m[97msimultaneously[0m, each of them using the state of all acres at
the beginning of the minute and changing to their new form by the end of that same minute. Changes
that happen during the minute don't affect each other.
@@ -167,8 +167,9 @@ After 10 minutes:
||||||||||
After 10 minutes, there are 37 wooded acres and 31 lumberyards. Multiplying the number of wooded
-acres by the number of lumberyards gives the total resource value after ten minutes: 37 * 31 = 1147.
+acres by the number of lumberyards gives the total [1m[97mresource value[0m after ten minutes: 37 * 31 =
+[1m[97m1147[0m.
-What will the total resource value of the lumber collection area be after 10 minutes?
+[1m[97mWhat will the total resource value of the lumber collection area be after 10 minutes?[0m
diff --git a/18/part2 b/18/part2
@@ -1,8 +1,184 @@
--- Part Two ---
-This important natural resource will need to last for at least thousands of years. Are the Elves
-collecting this lumber sustainably?
+You arrive at the vault only to discover that there is not one vault, but [1m[97mfour[0m - each with its own
+entrance.
-What will the total resource value of the lumber collection area be after 1000000000 minutes?
+On your map, find the area in the middle that looks like this:
+
+...
+.@.
+...
+
+Update your map to instead use the correct data:
+
+@#@
+###
+@#@
+
+This change will split your map into four separate sections, each with its own entrance:
+
+####### #######
+#a.#Cd# #a.#Cd#
+##...## ##[1m[97m@#@[0m##
+##.@.## --> ##[1m[97m###[0m##
+##...## ##[1m[97m@#@[0m##
+#cB#Ab# #cB#Ab#
+####### #######
+
+Because some of the keys are for doors in other vaults, it would take much too long to collect all
+of the keys by yourself. Instead, you deploy four remote-controlled robots. Each starts at one of
+the entrances (@).
+
+Your goal is still to [1m[97mcollect all of the keys in the fewest steps[0m, but now, each robot has its own
+position and can move independently. You can only remotely control a single robot at a time.
+Collecting a key instantly unlocks any corresponding doors, regardless of the vault in which the key
+or door is found.
+
+For example, in the map above, the top-left robot first collects key a, unlocking door A in the
+bottom-right vault:
+
+#######
+#@.#Cd#
+##.#@##
+#######
+##@#@##
+#cB#.b#
+#######
+
+Then, the bottom-right robot collects key b, unlocking door B in the bottom-left vault:
+
+#######
+#@.#Cd#
+##.#@##
+#######
+##@#.##
+#c.#.@#
+#######
+
+Then, the bottom-left robot collects key c:
+
+#######
+#@.#.d#
+##.#@##
+#######
+##.#.##
+#@.#.@#
+#######
+
+Finally, the top-right robot collects key d:
+
+#######
+#@.#.@#
+##.#.##
+#######
+##.#.##
+#@.#.@#
+#######
+
+In this example, it only took [1m[97m8[0m steps to collect all of the keys.
+
+Sometimes, multiple robots might have keys available, or a robot might have to wait for multiple
+keys to be collected:
+
+###############
+#d.ABC.#.....a#
+######@#@######
+###############
+######@#@######
+#b.....#.....c#
+###############
+
+First, the top-right, bottom-left, and bottom-right robots take turns collecting keys a, b, and c, a
+total of 6 + 6 + 6 = 18 steps. Then, the top-left robot can access key d, spending another 6 steps;
+collecting all of the keys here takes a minimum of [1m[97m24[0m steps.
+
+Here's a more complex example:
+
+#############
+#DcBa.#.GhKl#
+#.###@#@#I###
+#e#d#####j#k#
+###C#@#@###J#
+#fEbA.#.FgHi#
+#############
+
+
+ - Top-left robot collects key a.
+
+ - Bottom-left robot collects key b.
+
+ - Top-left robot collects key c.
+
+ - Bottom-left robot collects key d.
+
+ - Top-left robot collects key e.
+
+ - Bottom-left robot collects key f.
+
+ - Bottom-right robot collects key g.
+
+ - Top-right robot collects key h.
+
+ - Bottom-right robot collects key i.
+
+ - Top-right robot collects key j.
+
+ - Bottom-right robot collects key k.
+
+ - Top-right robot collects key l.
+
+
+In the above example, the fewest steps to collect all of the keys is [1m[97m32[0m.
+
+Here's an example with more choices:
+
+#############
+#g#f.D#..h#l#
+#F###e#E###.#
+#dCba@#@BcIJ#
+#############
+#nK.L@#@G...#
+#M###N#H###.#
+#o#m..#i#jk.#
+#############
+
+One solution with the fewest steps is:
+
+
+ - Top-left robot collects key e.
+
+ - Top-right robot collects key h.
+
+ - Bottom-right robot collects key i.
+
+ - Top-left robot collects key a.
+
+ - Top-left robot collects key b.
+
+ - Top-right robot collects key c.
+
+ - Top-left robot collects key d.
+
+ - Top-left robot collects key f.
+
+ - Top-left robot collects key g.
+
+ - Bottom-right robot collects key k.
+
+ - Bottom-right robot collects key j.
+
+ - Top-right robot collects key l.
+
+ - Bottom-left robot collects key n.
+
+ - Bottom-left robot collects key m.
+
+ - Bottom-left robot collects key o.
+
+
+This example requires at least [1m[97m72[0m steps to collect all keys.
+
+After updating your map and using the remote-controlled robots, [1m[97mwhat is the fewest steps necessary
+to collect all of the keys?[0m
diff --git a/19/part1 b/19/part1
@@ -3,25 +3,25 @@
With the Elves well on their way constructing the North Pole base, you turn your attention back to
understanding the inner workings of programming the device.
-You can't help but notice that the device's opcodes don't contain any flow control like jump
+You can't help but notice that the device's opcodes don't contain any [1m[97mflow control[0m like jump
instructions. The device's manual goes on to explain:
-"In programs where flow control is required, the instruction pointer can be bound to a register so
+"In programs where flow control is required, the instruction pointer can be [1m[97mbound to a register[0m so
that it can be manipulated directly. This way, setr/seti can function as absolute jumps, addr/addi
can function as relative jumps, and other opcodes can cause truly fascinating effects."
This mechanism is achieved through a declaration like #ip 1, which would modify register 1 so that
accesses to it let the program indirectly access the instruction pointer itself. To compensate for
-this kind of binding, there are now six registers (numbered 0 through 5); the five not bound to the
+this kind of binding, there are now [1m[97msix[0m registers (numbered 0 through 5); the five not bound to the
instruction pointer behave as normal. Otherwise, the same rules apply as the last time you worked
with this device.
-When the instruction pointer is bound to a register, its value is written to that register just
+When the [1m[97minstruction pointer[0m is bound to a register, its value is written to that register just
before each instruction is executed, and the value of that register is written back to the
instruction pointer immediately after each instruction finishes execution. Afterward, move to the
next instruction by adding one to the instruction pointer, even if the value in the instruction
pointer was just updated by an instruction. (Because of this, instructions must effectively set the
-instruction pointer to the instruction before the one they want executed next.)
+instruction pointer to the instruction [1m[97mbefore[0m the one they want executed next.)
The instruction pointer is 0 during the first instruction, 1 during the second, and so on. If the
instruction pointer ever causes the device to attempt to load an instruction outside the
@@ -72,21 +72,21 @@ is very similar to the instruction before it: 6 is stored in register 2, and the
is left with the value 2.
- The instruction pointer is 2, which points at the instruction addi 0 1 0. This is like a
-relative jump: the value of the instruction pointer, 2, is loaded into register 0. Then, addi finds
+[1m[97mrelative jump[0m: the value of the instruction pointer, 2, is loaded into register 0. Then, addi finds
the result of adding the value in register 0 and the value 1, storing the result, 3, back in
register 0. Register 0 is then copied back to the instruction pointer, which will cause it to end up
1 larger than it would have otherwise and skip the next instruction (addr 1 2 3) entirely. Finally,
1 is added to the instruction pointer.
- - The instruction pointer is 4, so the instruction setr 1 0 0 is run. This is like an absolute
-jump: it copies the value contained in register 1, 5, into register 0, which causes it to end up in
-the instruction pointer. The instruction pointer is then incremented, leaving it at 6.
+ - The instruction pointer is 4, so the instruction setr 1 0 0 is run. This is like an
+[1m[97mabsolute jump[0m: it copies the value contained in register 1, 5, into register 0, which causes it to
+end up in the instruction pointer. The instruction pointer is then incremented, leaving it at 6.
- The instruction pointer is 6, so the instruction seti 9 0 5 stores 9 into register 5. The
instruction pointer is incremented, causing it to point outside the program, and so the program
ends.
-What value is left in register 0 when the background process halts?
+[1m[97mWhat value is left in register 0[0m when the background process halts?
diff --git a/19/part2 b/19/part2
@@ -1,8 +1,58 @@
--- Part Two ---
-A new background process immediately spins up in its place. It appears identical, but on closer
-inspection, you notice that this time, register 0 started with the value 1.
+You aren't sure how large Santa's ship is. You aren't even sure if you'll need to use this thing on
+Santa's ship, but it doesn't hurt to be prepared. You figure Santa's ship might fit in a
+[1m[97m100x100[0m square.
-What value is left in register 0 when this new background process halts?
+The beam gets wider as it travels away from the emitter; you'll need to be a minimum distance away
+to fit a square of that size into the beam fully. (Don't rotate the square; it should be aligned to
+the same axes as the drone grid.)
+
+For example, suppose you have the following tractor beam readings:
+
+#.......................................
+.#......................................
+..##....................................
+...###..................................
+....###.................................
+.....####...............................
+......#####.............................
+......######............................
+.......#######..........................
+........########........................
+.........#########......................
+..........#########.....................
+...........##########...................
+...........############.................
+............############................
+.............#############..............
+..............##############............
+...............###############..........
+................###############.........
+................#################.......
+.................########[1m[97mO[0mOOOOOOOOO.....
+..................#######OOOOOOOOOO#....
+...................######OOOOOOOOOO###..
+....................#####OOOOOOOOOO#####
+.....................####OOOOOOOOOO#####
+.....................####OOOOOOOOOO#####
+......................###OOOOOOOOOO#####
+.......................##OOOOOOOOOO#####
+........................#OOOOOOOOOO#####
+.........................OOOOOOOOOO#####
+..........................##############
+..........................##############
+...........................#############
+............................############
+.............................###########
+
+In this example, the [1m[97m10x10[0m square closest to the emitter that fits entirely within the tractor beam
+has been marked O. Within it, the point closest to the emitter (the only highlighted [1m[97mO[0m) is at X=25,
+Y=20.
+
+Find the [1m[97m100x100[0m square closest to the emitter that fits entirely within the tractor beam; within
+that square, find the point closest to the emitter. [1m[97mWhat value do you get if you take that point's
+X coordinate, multiply it by 10000, then add the point's Y coordinate?[0m (In the example above, this
+would be 250020.)
diff --git a/20/part1 b/20/part1
@@ -3,7 +3,7 @@
While you were learning about instruction pointers, the Elves made considerable progress. When you
look up, you discover that the North Pole base construction project has completely surrounded you.
-The area you are in is made up entirely of rooms and doors. The rooms are arranged in a grid, and
+The area you are in is made up entirely of [1m[97mrooms[0m and [1m[97mdoors[0m. The rooms are arranged in a grid, and
rooms only connect to adjacent rooms when a door is present between them.
For example, drawing rooms as ., walls as #, doors as | or -, your current position as X, and where
@@ -16,14 +16,14 @@ north is up, the area you're in might look like this:
#####
You get the attention of a passing construction Elf and ask for a map. "I don't have time to draw
-out a map of this place - it's huge. Instead, I can give you directions to every room in the
-facility!" He writes down some directions on a piece of parchment and runs off. In the example
-above, the instructions might have been ^WNE$, a regular expression or "regex" (your puzzle input).
+out a map of this place - it's [1m[97mhuge[0m. Instead, I can give you directions to [1m[97mevery room in the
+facility[0m!" He writes down some directions on a piece of parchment and runs off. In the example
+above, the instructions might have been ^WNE$, a regular expression or "[1m[97mregex[0m" (your puzzle input).
The regex matches routes (like WNE for "west, north, east") that will take you from your current
-room through various doors in the facility. In aggregate, the routes will take you through every
-door in the facility at least once; mapping out all of these routes will let you build a proper map
-and find your way around.
+room through various doors in the facility. In aggregate, the routes will take you through
+[1m[97mevery door in the facility at least once[0m; mapping out all of these routes will let you build a
+proper map and find your way around.
^ and $ are at the beginning and end of your regex; these just mean that the regex doesn't match
anything outside the routes it describes. (Specifically, ^ matches the start of the route, and $
@@ -31,12 +31,12 @@ matches the end of it.) These characters will not appear elsewhere in the regex.
The rest of the regex matches various sequences of the characters N (north), S (south), E (east),
and W (west). In the example above, ^WNE$ matches only one route, WNE, which means you can move
-west, then north, then east from your current position. Sequences of letters like this always match
+[1m[97mwest, then north, then east[0m from your current position. Sequences of letters like this always match
that exact route in the same order.
-Sometimes, the route can branch. A branch is given by a list of options separated by pipes (|) and
+Sometimes, the route can [1m[97mbranch[0m. A branch is given by a [1m[97mlist of options[0m separated by pipes (|) and
wrapped in parentheses. So, ^N(E|W)N$ contains a branch: after going north, you must choose to go
-either east or west before finishing your route by going north again. By tracing out the possible
+[1m[97meither east or west[0m before finishing your route by going north again. By tracing out the possible
routes after branching, you can determine where the doors are and, therefore, where the rooms are in
the facility.
@@ -92,7 +92,7 @@ producing a finished map of the facility:
#.|.|.|.#
#########
-Sometimes, a list of options can have an empty option, like (NEWS|WNSE|). This means that routes at
+Sometimes, a list of options can have an [1m[97mempty option[0m, like (NEWS|WNSE|). This means that routes at
this point could effectively skip the options in parentheses and move on immediately. For example,
consider this regex and the corresponding map:
@@ -118,28 +118,28 @@ matches all of the following routes (and more that aren't listed here):
- ENNWSWWSSSEENEENNN
- - ENNWSWWNEWSSSSEENEENNN
+ - ENNWSWW[1m[97mNEWS[0mSSSEENEENNN
- - ENNWSWWNEWSSSSEENEESWENNNN
+ - ENNWSWW[1m[97mNEWS[0mSSSEENEE[1m[97mSWEN[0mNNN
- - ENNWSWWSSSEENWNSEEENNN
+ - ENNWSWWSSSEEN[1m[97mWNSE[0mEENNN
By following the various routes the regex matches, a full map of all of the doors and rooms in the
facility can be assembled.
-To get a sense for the size of this facility, you'd like to determine which room is furthest from
-you: specifically, you would like to find the room for which the shortest path to that room would
-require passing through the most doors.
+To get a sense for the size of this facility, you'd like to determine which room is
+[1m[97mfurthest[0m from you: specifically, you would like to find the room for which the [1m[97mshortest path to that
+room would require passing through the most doors[0m.
- - In the first example (^WNE$), this would be the north-east corner 3 doors away.
+ - In the first example (^WNE$), this would be the north-east corner [1m[97m3[0m doors away.
- - In the second example (^ENWWW(NEEE|SSE(EE|N))$), this would be the south-east corner 10 doors
-away.
+ - In the second example (^ENWWW(NEEE|SSE(EE|N))$), this would be the south-east corner
+[1m[97m10[0m doors away.
- In the third example (^ENNWSWW(NEWS|)SSSEEN(WNSE|)EE(SWEN|)NNN$), this would be the north-east
-corner 18 doors away.
+corner [1m[97m18[0m doors away.
Here are a few more examples:
@@ -180,7 +180,7 @@ Furthest room requires passing 31 doors
#.#.|.|.|.#.|.#
###############
-What is the largest number of doors you would be required to pass through to reach a room? That is,
+[1m[97mWhat is the largest number of doors you would be required to pass through to reach a room?[0m That is,
find the room for which the shortest path from your starting location to that room would require
passing through the most doors; what is the fewest doors you can pass through to reach it?
diff --git a/20/part2 b/20/part2
@@ -1,8 +1,207 @@
--- Part Two ---
-Okay, so the facility is big.
+Strangely, the exit isn't open when you reach it. Then, you remember: the ancient Plutonians were
+famous for building [1m[97mrecursive spaces[0m.
-How many rooms have a shortest path from your current location that pass through at least 1000
-doors?
+The marked connections in the maze aren't portals: they [1m[97mphysically connect[0m to a larger or smaller
+copy of the maze. Specifically, the labeled tiles around the inside edge actually connect to a
+smaller copy of the same maze, and the smaller copy's inner labeled tiles connect to yet a
+[1m[97msmaller[0m copy, and so on.
+
+When you enter the maze, you are at the outermost level; when at the outermost level, only the outer
+labels AA and ZZ function (as the start and end, respectively); all other outer labeled tiles are
+effectively walls. At any other level, AA and ZZ count as walls, but the other outer labeled tiles
+bring you one level outward.
+
+Your goal is to find a path through the maze that brings you back to ZZ at the outermost level of
+the maze.
+
+In the first example above, the shortest path is now the loop around the right side. If the starting
+level is 0, then taking the previously-shortest path would pass through BC (to level 1), DE (to
+level 2), and FG (back to level 1). Because this is not the outermost level, ZZ is a wall, and the
+only option is to go back around to BC, which would only send you even deeper into the recursive
+maze.
+
+In the second example above, there is no path that brings you to ZZ at the outermost level.
+
+Here is a more interesting example:
+
+ Z L X W C
+ Z P Q B K
+ ###########.#.#.#.#######.###############
+ #...#.......#.#.......#.#.......#.#.#...#
+ ###.#.#.#.#.#.#.#.###.#.#.#######.#.#.###
+ #.#...#.#.#...#.#.#...#...#...#.#.......#
+ #.###.#######.###.###.#.###.###.#.#######
+ #...#.......#.#...#...#.............#...#
+ #.#########.#######.#.#######.#######.###
+ #...#.# F R I Z #.#.#.#
+ #.###.# D E C H #.#.#.#
+ #.#...# #...#.#
+ #.###.# #.###.#
+ #.#....OA WB..#.#..ZH
+ #.###.# #.#.#.#
+CJ......# #.....#
+ ####### #######
+ #.#....CK #......IC
+ #.###.# #.###.#
+ #.....# #...#.#
+ ###.### #.#.#.#
+XF....#.# RF..#.#.#
+ #####.# #######
+ #......CJ NM..#...#
+ ###.#.# #.###.#
+RE....#.# #......RF
+ ###.### X X L #.#.#.#
+ #.....# F Q P #.#.#.#
+ ###.###########.###.#######.#########.###
+ #.....#...#.....#.......#...#.....#.#...#
+ #####.#.###.#######.#######.###.###.#.#.#
+ #.......#.......#.#.#.#.#...#...#...#.#.#
+ #####.###.#####.#.#.#.#.###.###.#.###.###
+ #.......#.....#.#...#...............#...#
+ #############.#.#.###.###################
+ A O F N
+ A A D M
+
+One shortest path through the maze is the following:
+
+
+ - Walk from AA to XF (16 steps)
+
+ - Recurse into level 1 through XF (1 step)
+
+ - Walk from XF to CK (10 steps)
+
+ - Recurse into level 2 through CK (1 step)
+
+ - Walk from CK to ZH (14 steps)
+
+ - Recurse into level 3 through ZH (1 step)
+
+ - Walk from ZH to WB (10 steps)
+
+ - Recurse into level 4 through WB (1 step)
+
+ - Walk from WB to IC (10 steps)
+
+ - Recurse into level 5 through IC (1 step)
+
+ - Walk from IC to RF (10 steps)
+
+ - Recurse into level 6 through RF (1 step)
+
+ - Walk from RF to NM (8 steps)
+
+ - Recurse into level 7 through NM (1 step)
+
+ - Walk from NM to LP (12 steps)
+
+ - Recurse into level 8 through LP (1 step)
+
+ - Walk from LP to FD (24 steps)
+
+ - Recurse into level 9 through FD (1 step)
+
+ - Walk from FD to XQ (8 steps)
+
+ - Recurse into level 10 through XQ (1 step)
+
+ - Walk from XQ to WB (4 steps)
+
+ - Return to level 9 through WB (1 step)
+
+ - Walk from WB to ZH (10 steps)
+
+ - Return to level 8 through ZH (1 step)
+
+ - Walk from ZH to CK (14 steps)
+
+ - Return to level 7 through CK (1 step)
+
+ - Walk from CK to XF (10 steps)
+
+ - Return to level 6 through XF (1 step)
+
+ - Walk from XF to OA (14 steps)
+
+ - Return to level 5 through OA (1 step)
+
+ - Walk from OA to CJ (8 steps)
+
+ - Return to level 4 through CJ (1 step)
+
+ - Walk from CJ to RE (8 steps)
+
+ - Return to level 3 through RE (1 step)
+
+ - Walk from RE to IC (4 steps)
+
+ - Recurse into level 4 through IC (1 step)
+
+ - Walk from IC to RF (10 steps)
+
+ - Recurse into level 5 through RF (1 step)
+
+ - Walk from RF to NM (8 steps)
+
+ - Recurse into level 6 through NM (1 step)
+
+ - Walk from NM to LP (12 steps)
+
+ - Recurse into level 7 through LP (1 step)
+
+ - Walk from LP to FD (24 steps)
+
+ - Recurse into level 8 through FD (1 step)
+
+ - Walk from FD to XQ (8 steps)
+
+ - Recurse into level 9 through XQ (1 step)
+
+ - Walk from XQ to WB (4 steps)
+
+ - Return to level 8 through WB (1 step)
+
+ - Walk from WB to ZH (10 steps)
+
+ - Return to level 7 through ZH (1 step)
+
+ - Walk from ZH to CK (14 steps)
+
+ - Return to level 6 through CK (1 step)
+
+ - Walk from CK to XF (10 steps)
+
+ - Return to level 5 through XF (1 step)
+
+ - Walk from XF to OA (14 steps)
+
+ - Return to level 4 through OA (1 step)
+
+ - Walk from OA to CJ (8 steps)
+
+ - Return to level 3 through CJ (1 step)
+
+ - Walk from CJ to RE (8 steps)
+
+ - Return to level 2 through RE (1 step)
+
+ - Walk from RE to XQ (14 steps)
+
+ - Return to level 1 through XQ (1 step)
+
+ - Walk from XQ to FD (8 steps)
+
+ - Return to level 0 through FD (1 step)
+
+ - Walk from FD to ZZ (18 steps)
+
+
+This path takes a total of [1m[97m396[0m steps to move from AA at the outermost layer to ZZ at the outermost
+layer.
+
+In your maze, when accounting for recursion, [1m[97mhow many steps does it take to get from the open tile
+marked AA to the open tile marked ZZ, both at the outermost layer?[0m
diff --git a/21/part1 b/21/part1
@@ -14,28 +14,28 @@ After a little research, you discover two important facts about the behavior of
First, you discover that the device is hard-wired to always send you back in time in 500-year
increments. Changing this is probably not feasible.
-Second, you discover the activation system (your puzzle input) for the time travel module.
-Currently, it appears to run forever without halting.
+Second, you discover the [1m[97mactivation system[0m (your puzzle input) for the time travel module.
+Currently, it appears to [1m[97mrun forever without halting[0m.
-If you can cause the activation system to halt at a specific moment, maybe you can make the device
-send you so far back in time that you cause an integer underflow in time itself and wrap around back
+If you can cause the activation system to [1m[97mhalt[0m at a specific moment, maybe you can make the device
+send you so far back in time that you cause an integer underflow [1m[97min time itself[0m and wrap around back
to your current time!
The device executes the program as specified in manual section one and manual section two.
Your goal is to figure out how the program works and cause it to halt. You can only control
-register 0; every other register begins at 0 as usual.
+[1m[97mregister 0[0m; every other register begins at 0 as usual.
Because time travel is a dangerous activity, the activation system begins with a few instructions
-which verify that bitwise AND (via bani) does a numeric operation and not an operation as if the
+which verify that [1m[97mbitwise AND[0m (via bani) does a [1m[97mnumeric[0m operation and [1m[97mnot[0m an operation as if the
inputs were interpreted as strings. If the test fails, it enters an infinite loop re-running the
test instead of allowing the program to execute normally. If the test passes, the program
-continues, and assumes that all other bitwise operations (banr, bori, and borr) also interpret their
-inputs as numbers. (Clearly, the Elves who wrote this system were worried that someone might
+continues, and assumes that [1m[97mall other bitwise operations[0m (banr, bori, and borr) also interpret their
+inputs as [1m[97mnumbers[0m. (Clearly, the Elves who wrote this system were worried that someone might
introduce a bug while trying to emulate this system with a scripting language.)
-What is the lowest non-negative integer value for register 0 that causes the program to halt after
-executing the fewest instructions? (Executing the same instruction multiple times counts as multiple
+[1m[97mWhat is the lowest non-negative integer value for register 0 that causes the program to halt after
+executing the fewest instructions?[0m (Executing the same instruction multiple times counts as multiple
instructions executed.)
diff --git a/21/part2 b/21/part2
@@ -1,9 +1,27 @@
--- Part Two ---
-In order to determine the timing window for your underflow exploit, you also need an upper bound:
+There are many areas the springdroid can't reach. You flip through the manual and discover a way to
+[1m[97mincrease its sensor range[0m.
-What is the lowest non-negative integer value for register 0 that causes the program to halt after
-executing the most instructions? (The program must actually halt; running forever does not count as
-halting.)
+Instead of ending your springcode program with WALK, use RUN. Doing this will enable
+[1m[97mextended sensor mode[0m, capable of sensing ground up to [1m[97mnine tiles away[0m. This data is available in
+[1m[97mfive new read-only registers[0m:
+
+
+ - Register E indicates whether there is ground [1m[97mfive[0m tiles away.
+
+ - Register F indicates whether there is ground [1m[97msix[0m tiles away.
+
+ - Register G indicates whether there is ground [1m[97mseven[0m tiles away.
+
+ - Register H indicates whether there is ground [1m[97meight[0m tiles away.
+
+ - Register I indicates whether there is ground [1m[97mnine[0m tiles away.
+
+
+All other functions remain the same.
+
+Successfully survey the rest of the hull by ending your program with RUN. [1m[97mWhat amount of hull
+damage does the springdroid now report?[0m
diff --git a/22/part1 b/22/part1
@@ -12,17 +12,17 @@ he's not sure where he is. Scanning the region briefly, you discover one life s
system nearby; his friend must have taken shelter there. The man asks if you can go there to
retrieve his friend.
-The cave is divided into square regions which are either dominantly rocky, narrow, or wet (called
-its type). Each region occupies exactly one coordinate in X,Y format where X and Y are integers and
-zero or greater. (Adjacent regions can be the same type.)
+The cave is divided into square [1m[97mregions[0m which are either dominantly [1m[97mrocky[0m, [1m[97mnarrow[0m, or
+[1m[97mwet[0m (called its [1m[97mtype[0m). Each region occupies exactly one [1m[97mcoordinate[0m in X,Y format where X and Y are
+integers and zero or greater. (Adjacent regions can be the same type.)
-The scan (your puzzle input) is not very detailed: it only reveals the depth of the cave system and
-the coordinates of the target. However, it does not reveal the type of each region. The mouth of the
+The scan (your puzzle input) is not very detailed: it only reveals the [1m[97mdepth[0m of the cave system and
+the [1m[97mcoordinates of the target[0m. However, it does not reveal the type of each region. The mouth of the
cave is at 0,0.
The man explains that due to the unusual geology in the area, there is a method to determine any
-region's type based on its erosion level. The erosion level of a region can be determined from its
-geologic index. The geologic index can be determined using the first rule that applies from the list
+region's type based on its [1m[97merosion level[0m. The erosion level of a region can be determined from its
+[1m[97mgeologic index[0m. The geologic index can be determined using the first rule that applies from the list
below:
@@ -34,18 +34,18 @@ below:
- If the region's X coordinate is 0, the geologic index is its Y coordinate times 48271.
- - Otherwise, the region's geologic index is the result of multiplying the erosion levels of the
-regions at X-1,Y and X,Y-1.
+ - Otherwise, the region's geologic index is the result of multiplying the erosion
+[1m[97mlevels[0m of the regions at X-1,Y and X,Y-1.
-A region's erosion level is its geologic index plus the cave system's depth, all modulo 20183. Then:
+A region's [1m[97merosion level[0m is its [1m[97mgeologic index[0m plus the cave system's [1m[97mdepth[0m, all modulo 20183. Then:
- - If the erosion level modulo 3 is 0, the region's type is rocky.
+ - If the [1m[97merosion level modulo 3[0m is 0, the region's type is [1m[97mrocky[0m.
- - If the erosion level modulo 3 is 1, the region's type is wet.
+ - If the [1m[97merosion level modulo 3[0m is 1, the region's type is [1m[97mwet[0m.
- - If the erosion level modulo 3 is 2, the region's type is narrow.
+ - If the [1m[97merosion level modulo 3[0m is 2, the region's type is [1m[97mnarrow[0m.
For example, suppose the cave system's depth is 510 and the target's coordinates are 10,10. Using %
@@ -53,27 +53,28 @@ to represent the modulo operator, the cavern would look as follows:
- At 0,0, the geologic index is 0. The erosion level is (0 + 510) % 20183 = 510. The type is 510 %
-3 = 0, rocky.
+3 = 0, [1m[97mrocky[0m.
- At 1,0, because the Y coordinate is 0, the geologic index is 1 * 16807 = 16807. The erosion level
-is (16807 + 510) % 20183 = 17317. The type is 17317 % 3 = 1, wet.
+is (16807 + 510) % 20183 = 17317. The type is 17317 % 3 = 1, [1m[97mwet[0m.
- At 0,1, because the X coordinate is 0, the geologic index is 1 * 48271 = 48271. The erosion
-level is (48271 + 510) % 20183 = 8415. The type is 8415 % 3 = 0, rocky.
+level is (48271 + 510) % 20183 = 8415. The type is 8415 % 3 = 0, [1m[97mrocky[0m.
- At 1,1, neither coordinate is 0 and it is not the coordinate of the target, so the geologic index
is the erosion level of 0,1 (8415) times the erosion level of 1,0 (17317), 8415 * 17317 = 145722555.
-The erosion level is (145722555 + 510) % 20183 = 1805. The type is 1805 % 3 = 2, narrow.
+The erosion level is (145722555 + 510) % 20183 = 1805. The type is 1805 % 3 = 2,
+[1m[97mnarrow[0m.
- At 10,10, because they are the target's coordinates, the geologic index is 0. The erosion level
-is (0 + 510) % 20183 = 510. The type is 510 % 3 = 0, rocky.
+is (0 + 510) % 20183 = 510. The type is 510 % 3 = 0, [1m[97mrocky[0m.
Drawing this same cave system with rocky as ., wet as =, narrow as |, the mouth as M, the target as
T, with 0,0 in the top-left corner, X increasing to the right, and Y increasing downward, the
top-left corner of the map looks like this:
-M=.|=.|.|=.|=|=.
+[1m[97mM[0m=.|=.|.|=.|=|=.
.|=|=|||..|.=...
.==|....||=..|==
=.|....|.==.|==.
@@ -83,23 +84,23 @@ M=.|=.|.|=.|=|=.
|..==||=.|==|===
.=..===..=|.|||.
.======|||=|=.|=
-.===|=|===T===||
+.===|=|===[1m[97mT[0m===||
=|||...|==..|=.|
=.=|=.=..=.||==|
||=|=...|==.=|==
|=.=||===.|||===
||.|==.|.|.||=||
-Before you go in, you should determine the risk level of the area. For the rectangle that has a
+Before you go in, you should determine the [1m[97mrisk level[0m of the area. For the rectangle that has a
top-left corner of region 0,0 and a bottom-right corner of the region containing the target, add up
the risk level of each individual region: 0 for rocky regions, 1 for wet regions, and 2 for narrow
regions.
In the cave system above, because the mouth is at 0,0 and the target is at 10,10, adding up the risk
level of all regions with an X coordinate from 0 to 10 and a Y coordinate from 0 to 10, this total
-is 114.
+is [1m[97m114[0m.
-What is the total risk level for the smallest rectangle that includes 0,0 and the target's
-coordinates?
+[1m[97mWhat is the total risk level for the smallest rectangle that includes 0,0 and the target's
+coordinates?[0m
diff --git a/22/part2 b/22/part2
@@ -1,302 +1,22 @@
--- Part Two ---
-Okay, it's time to go rescue the man's friend.
+After a while, you realize your shuffling skill won't improve much more with merely a single deck of
+cards. You ask every 3D printer on the ship to make you some more cards while you check on the ship
+repairs. While reviewing the work the droids have finished so far, you think you see Halley's Comet
+fly past!
-As you leave, he hands you some tools: a torch and some climbing gear. You can't equip both tools at
-once, but you can choose to use neither.
+When you get back, you discover that the 3D printers have combined their power to create for you a
+single, giant, brand new, [1m[97mfactory order[0m deck of [1m[97m119315717514047 space cards[0m.
-Tools can only be used in certain regions:
+Finally, a deck of cards worthy of shuffling!
+You decide to apply your complete shuffle process (your puzzle input) to the deck
+[1m[97m101741582076661 times in a row[0m.
- - In rocky regions, you can use the climbing gear or the torch. You cannot use neither (you'll
-likely slip and fall).
+You'll need to be careful, though - one wrong move with this many cards and you might
+[1m[97moverflow[0m your entire ship!
- - In wet regions, you can use the climbing gear or neither tool. You cannot use the torch (if it
-gets wet, you won't have a light source).
-
- - In narrow regions, you can use the torch or neither tool. You cannot use the climbing gear (it's
-too bulky to fit).
-
-
-You start at 0,0 (the mouth of the cave) with the torch equipped and must reach the target
-coordinates as quickly as possible. The regions with negative X or Y are solid rock and cannot be
-traversed. The fastest route might involve entering regions beyond the X or Y coordinate of the
-target.
-
-You can move to an adjacent region (up, down, left, or right; never diagonally) if your currently
-equipped tool allows you to enter that region. Moving to an adjacent region takes one minute. (For
-example, if you have the torch equipped, you can move between rocky and narrow regions, but cannot
-enter wet regions.)
-
-You can change your currently equipped tool or put both away if your new equipment would be valid
-for your current region. Switching to using the climbing gear, torch, or neither always takes seven
-minutes, regardless of which tools you start with. (For example, if you are in a rocky region, you
-can switch from the torch to the climbing gear, but you cannot switch to neither.)
-
-Finally, once you reach the target, you need the torch equipped before you can find him in the dark.
-The target is always in a rocky region, so if you arrive there with climbing gear equipped, you will
-need to spend seven minutes switching to your torch.
-
-For example, using the same cave system as above, starting in the top left corner (0,0) and moving
-to the bottom right corner (the target, 10,10) as quickly as possible, one possible route is as
-follows, with your current position marked X:
-
-Initially:
-X=.|=.|.|=.|=|=.
-.|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Down:
-M=.|=.|.|=.|=|=.
-X|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Right:
-M=.|=.|.|=.|=|=.
-.X=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Switch from using the torch to neither tool:
-M=.|=.|.|=.|=|=.
-.X=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Right 3:
-M=.|=.|.|=.|=|=.
-.|=|X|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Switch from using neither tool to the climbing gear:
-M=.|=.|.|=.|=|=.
-.|=|X|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Down 7:
-M=.|=.|.|=.|=|=.
-.|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..X==..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Right:
-M=.|=.|.|=.|=|=.
-.|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..=X=..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Down 3:
-M=.|=.|.|=.|=|=.
-.|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||.X.|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Right:
-M=.|=.|.|=.|=|=.
-.|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||..X|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Down:
-M=.|=.|.|=.|=|=.
-.|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.X..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Right 4:
-M=.|=.|.|=.|=|=.
-.|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===T===||
-=|||...|==..|=.|
-=.=|=.=..=X||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Up 2:
-M=.|=.|.|=.|=|=.
-.|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===X===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-Switch from using the climbing gear to the torch:
-M=.|=.|.|=.|=|=.
-.|=|=|||..|.=...
-.==|....||=..|==
-=.|....|.==.|==.
-=|..==...=.|==..
-=||.=.=||=|=..|=
-|.=.===|||..=..|
-|..==||=.|==|===
-.=..===..=|.|||.
-.======|||=|=.|=
-.===|=|===X===||
-=|||...|==..|=.|
-=.=|=.=..=.||==|
-||=|=...|==.=|==
-|=.=||===.|||===
-||.|==.|.|.||=||
-
-This is tied with other routes as the fastest way to reach the target: 45 minutes. In it, 21 minutes
-are spent switching tools (three times, seven minutes each) and the remaining 24 minutes are spent
-moving.
-
-What is the fewest number of minutes you can take to reach the target?
+After shuffling your new, giant, [1m[97mfactory order[0m deck that many times, [1m[97mwhat number is on the card that
+ends up in position 2020?[0m
diff --git a/23/part1 b/23/part1
@@ -1,26 +1,26 @@
--- Day 23: Experimental Emergency Teleportation ---
Using your torch to search the darkness of the rocky cavern, you finally locate the man's friend: a
-small reindeer.
+small [1m[97mreindeer[0m.
You're not sure how it got so far in this cave. It looks sick - too sick to walk - and too heavy
for you to carry all the way back. Sleighs won't be invented for another 1500 years, of course.
-The only option is experimental emergency teleportation.
+The only option is [1m[97mexperimental emergency teleportation[0m.
-You hit the "experimental emergency teleportation" button on the device and push I accept the risk
-on no fewer than 18 different warning messages. Immediately, the device deploys hundreds of tiny
-nanobots which fly around the cavern, apparently assembling themselves into a very specific
-formation. The device lists the X,Y,Z position (pos) for each nanobot as well as its signal radius
-(r) on its tiny screen (your puzzle input).
+You hit the "experimental emergency teleportation" button on the device and push [1m[97mI accept the
+risk[0m on no fewer than 18 different warning messages. Immediately, the device deploys hundreds of
+tiny [1m[97mnanobots[0m which fly around the cavern, apparently assembling themselves into a very specific
+[1m[97mformation[0m. The device lists the X,Y,Z position (pos) for each nanobot as well as its [1m[97msignal
+radius[0m (r) on its tiny screen (your puzzle input).
-Each nanobot can transmit signals to any integer coordinate which is a distance away from it less
-than or equal to its signal radius (as measured by Manhattan distance). Coordinates a distance away
-of less than or equal to a nanobot's signal radius are said to be in range of that nanobot.
+Each nanobot can transmit signals to any integer coordinate which is a distance away from it
+[1m[97mless than or equal to[0m its signal radius (as measured by Manhattan distance). Coordinates a distance
+away of less than or equal to a nanobot's signal radius are said to be [1m[97min range[0m of that nanobot.
-Before you start the teleportation process, you should determine which nanobot is the strongest
-(that is, which has the largest signal radius) and then, for that nanobot, the total number of
-nanobots that are in range of it, including itself.
+Before you start the teleportation process, you should determine which nanobot is the
+[1m[97mstrongest[0m (that is, which has the largest signal radius) and then, for that nanobot, the
+[1m[97mtotal number of nanobots that are in range[0m of it, [1m[97mincluding itself[0m.
For example, given the following nanobots:
@@ -38,27 +38,27 @@ The strongest nanobot is the first one (position 0,0,0) because its signal radiu
Using that nanobot's location and signal radius, the following nanobots are in or out of range:
- - The nanobot at 0,0,0 is distance 0 away, and so it is in range.
+ - The nanobot at 0,0,0 is distance 0 away, and so it is [1m[97min range[0m.
- - The nanobot at 1,0,0 is distance 1 away, and so it is in range.
+ - The nanobot at 1,0,0 is distance 1 away, and so it is [1m[97min range[0m.
- - The nanobot at 4,0,0 is distance 4 away, and so it is in range.
+ - The nanobot at 4,0,0 is distance 4 away, and so it is [1m[97min range[0m.
- - The nanobot at 0,2,0 is distance 2 away, and so it is in range.
+ - The nanobot at 0,2,0 is distance 2 away, and so it is [1m[97min range[0m.
- - The nanobot at 0,5,0 is distance 5 away, and so it is not in range.
+ - The nanobot at 0,5,0 is distance 5 away, and so it is [1m[97mnot[0m in range.
- - The nanobot at 0,0,3 is distance 3 away, and so it is in range.
+ - The nanobot at 0,0,3 is distance 3 away, and so it is [1m[97min range[0m.
- - The nanobot at 1,1,1 is distance 3 away, and so it is in range.
+ - The nanobot at 1,1,1 is distance 3 away, and so it is [1m[97min range[0m.
- - The nanobot at 1,1,2 is distance 4 away, and so it is in range.
+ - The nanobot at 1,1,2 is distance 4 away, and so it is [1m[97min range[0m.
- - The nanobot at 1,3,1 is distance 5 away, and so it is not in range.
+ - The nanobot at 1,3,1 is distance 5 away, and so it is [1m[97mnot[0m in range.
-In this example, in total, 7 nanobots are in range of the nanobot with the largest signal radius.
+In this example, in total, [1m[97m7[0m nanobots are in range of the nanobot with the largest signal radius.
-Find the nanobot with the largest signal radius. How many nanobots are in range of its signals?
+Find the nanobot with the largest signal radius. [1m[97mHow many nanobots are in range[0m of its signals?
diff --git a/23/part2 b/23/part2
@@ -1,27 +1,22 @@
--- Part Two ---
-Now, you just need to figure out where to position yourself so that you're actually teleported when
-the nanobots activate.
+Packets sent to address 255 are handled by a device called a NAT (Not Always Transmitting). The NAT
+is responsible for managing power consumption of the network by blocking certain packets and
+watching for idle periods in the computers.
-To increase the probability of success, you need to find the coordinate which puts you in range of
-the largest number of nanobots. If there are multiple, choose one closest to your position (0,0,0,
-measured by manhattan distance).
+If a packet would be sent to address 255, the NAT receives it instead. The NAT remembers only the
+[1m[97mlast[0m packet it receives; that is, the data in each packet it receives overwrites the NAT's packet
+memory with the new packet's X and Y values.
-For example, given the following nanobot formation:
+The NAT also monitors all computers on the network. If all computers have [1m[97mempty incoming packet
+queues[0m and are [1m[97mcontinuously trying to receive packets[0m without sending packets, the network is
+considered [1m[97midle[0m.
-pos=<10,12,12>, r=2
-pos=<12,14,12>, r=2
-pos=<16,12,12>, r=4
-pos=<14,14,14>, r=6
-pos=<50,50,50>, r=200
-pos=<10,10,10>, r=5
+Once the network is idle, the NAT sends [1m[97monly the last packet it received[0m to address 0; this will
+cause the computers on the network to resume activity. In this way, the NAT can throttle power
+consumption of the network when the ship needs power in other areas.
-Many coordinates are in range of some of the nanobots in this formation. However, only the
-coordinate 12,12,12 is in range of the most nanobots: it is in range of the first five, but is not
-in range of the nanobot at 10,10,10. (All other coordinates are in range of fewer than five
-nanobots.) This coordinate's distance from 0,0,0 is 36.
-
-Find the coordinates that are in range of the largest number of nanobots. What is the shortest
-manhattan distance between any of those points and 0,0,0?
+Monitor packets released to the computer at address 0 by the NAT. [1m[97mWhat is the first Y value
+delivered by the NAT to the computer at address 0 twice in a row?[0m
diff --git a/24/part1 b/24/part1
@@ -6,25 +6,25 @@ friend, but quickly notices that the little reindeer caught some kind of cold wh
The portly man explains that this reindeer's immune system isn't similar to regular reindeer immune
systems:
-The immune system and the infection each have an army made up of several groups; each group consists
-of one or more identical units. The armies repeatedly fight until only one army has units
-remaining.
+The [1m[97mimmune system[0m and the [1m[97minfection[0m each have an army made up of several [1m[97mgroups[0m; each
+[1m[97mgroup[0m consists of one or more identical [1m[97munits[0m. The armies repeatedly [1m[97mfight[0m until only one army has
+units remaining.
-Units within a group all have the same hit points (amount of damage a unit can take before it is
-destroyed), attack damage (the amount of damage each unit deals), an attack type, an initiative
-(higher initiative units attack first and win ties), and sometimes weaknesses or immunities. Here is
-an example group:
+[1m[97mUnits[0m within a group all have the same [1m[97mhit points[0m (amount of damage a unit can take before it is
+destroyed), [1m[97mattack damage[0m (the amount of damage each unit deals), an [1m[97mattack type[0m, an
+[1m[97minitiative[0m (higher initiative units attack first and win ties), and sometimes
+[1m[97mweaknesses[0m or [1m[97mimmunities[0m. Here is an example group:
18 units each with 729 hit points (weak to fire; immune to cold, slashing)
with an attack that does 8 radiation damage at initiative 10
-Each group also has an effective power: the number of units in that group multiplied by their attack
+Each group also has an [1m[97meffective power[0m: the number of units in that group multiplied by their attack
damage. The above group has an effective power of 18 * 8 = 144. Groups never have zero or negative
units; instead, the group is removed from combat.
-Each fight consists of two phases: target selection and attacking.
+Each [1m[97mfight[0m consists of two phases: [1m[97mtarget selection[0m and [1m[97mattacking[0m.
-During the target selection phase, each group attempts to choose one target. In decreasing order of
+During the [1m[97mtarget selection[0m phase, each group attempts to choose one target. In decreasing order of
effective power, groups choose their targets; in a tie, the group with the higher initiative chooses
first. The attacking group chooses to target the group in the enemy army to which it would deal the
most damage (after accounting for weaknesses and immunities, but not accounting for whether the
@@ -39,18 +39,18 @@ attacking group.
At the end of the target selection phase, each group has selected zero or one groups to attack, and
each group is being attacked by zero or one groups.
-During the attacking phase, each group deals damage to the target it selected, if any. Groups attack
+During the [1m[97mattacking[0m phase, each group deals damage to the target it selected, if any. Groups attack
in decreasing order of initiative, regardless of whether they are part of the infection or the
immune system. (If a group contains no units, it cannot attack.)
The damage an attacking group deals to a defending group depends on the attacking group's attack
type and the defending group's immunities and weaknesses. By default, an attacking group would deal
-damage equal to its effective power to the defending group. However, if the defending group is
-immune to the attacking group's attack type, the defending group instead takes no damage; if the
-defending group is weak to the attacking group's attack type, the defending group instead takes
-double damage.
+damage equal to its [1m[97meffective power[0m to the defending group. However, if the defending group is
+[1m[97mimmune[0m to the attacking group's attack type, the defending group instead takes [1m[97mno damage[0m; if the
+defending group is [1m[97mweak[0m to the attacking group's attack type, the defending group instead takes
+[1m[97mdouble damage[0m.
-The defending group only loses whole units from damage; damage is always dealt in such a way that it
+The defending group only loses [1m[97mwhole units[0m from damage; damage is always dealt in such a way that it
kills the most units possible, and any remaining damage to a unit that does not immediately kill it
is ignored. For example, if a defending group contains 10 units with 10 hit points each and receives
75 damage, it loses exactly 7 units and is left with 3 units at full health.
@@ -191,9 +191,9 @@ Infection:
Group 1 contains 782 units
Group 2 contains 4434 units
-In the example above, the winning army ends up with 782 + 4434 = 5216 units.
+In the example above, the winning army ends up with 782 + 4434 = [1m[97m5216[0m units.
You scan the reindeer's condition (your puzzle input); the white-bearded man looks nervous. As it
-stands now, how many units would the winning army have?
+stands now, [1m[97mhow many units would the winning army have[0m?
diff --git a/24/part2 b/24/part2
@@ -1,150 +1,186 @@
--- Part Two ---
-Things aren't looking good for the reindeer. The man asks whether more milk and cookies would help
-you think.
-
-If only you could give the reindeer's immune system a boost, you might be able to change the outcome
-of the combat.
-
-A boost is an integer increase in immune system units' attack damage. For example, if you were to
-boost the above example's immune system's units by 1570, the armies would instead look like this:
-
-Immune System:
-17 units each with 5390 hit points (weak to radiation, bludgeoning) with
- an attack that does 6077 fire damage at initiative 2
-989 units each with 1274 hit points (immune to fire; weak to bludgeoning,
- slashing) with an attack that does 1595 slashing damage at initiative 3
-
-Infection:
-801 units each with 4706 hit points (weak to radiation) with an attack
- that does 116 bludgeoning damage at initiative 1
-4485 units each with 2961 hit points (immune to radiation; weak to fire,
- cold) with an attack that does 12 slashing damage at initiative 4
-
-With this boost, the combat proceeds differently:
-
-Immune System:
-Group 2 contains 989 units
-Group 1 contains 17 units
-Infection:
-Group 1 contains 801 units
-Group 2 contains 4485 units
-
-Infection group 1 would deal defending group 2 185832 damage
-Infection group 1 would deal defending group 1 185832 damage
-Infection group 2 would deal defending group 1 53820 damage
-Immune System group 2 would deal defending group 1 1577455 damage
-Immune System group 2 would deal defending group 2 1577455 damage
-Immune System group 1 would deal defending group 2 206618 damage
-
-Infection group 2 attacks defending group 1, killing 9 units
-Immune System group 2 attacks defending group 1, killing 335 units
-Immune System group 1 attacks defending group 2, killing 32 units
-Infection group 1 attacks defending group 2, killing 84 units
-
-Immune System:
-Group 2 contains 905 units
-Group 1 contains 8 units
-Infection:
-Group 1 contains 466 units
-Group 2 contains 4453 units
-
-Infection group 1 would deal defending group 2 108112 damage
-Infection group 1 would deal defending group 1 108112 damage
-Infection group 2 would deal defending group 1 53436 damage
-Immune System group 2 would deal defending group 1 1443475 damage
-Immune System group 2 would deal defending group 2 1443475 damage
-Immune System group 1 would deal defending group 2 97232 damage
-
-Infection group 2 attacks defending group 1, killing 8 units
-Immune System group 2 attacks defending group 1, killing 306 units
-Infection group 1 attacks defending group 2, killing 29 units
-
-Immune System:
-Group 2 contains 876 units
-Infection:
-Group 2 contains 4453 units
-Group 1 contains 160 units
-
-Infection group 2 would deal defending group 2 106872 damage
-Immune System group 2 would deal defending group 2 1397220 damage
-Immune System group 2 would deal defending group 1 1397220 damage
-
-Infection group 2 attacks defending group 2, killing 83 units
-Immune System group 2 attacks defending group 2, killing 427 units
-
-After a few fights...
-
-Immune System:
-Group 2 contains 64 units
-Infection:
-Group 2 contains 214 units
-Group 1 contains 19 units
-
-Infection group 2 would deal defending group 2 5136 damage
-Immune System group 2 would deal defending group 2 102080 damage
-Immune System group 2 would deal defending group 1 102080 damage
-
-Infection group 2 attacks defending group 2, killing 4 units
-Immune System group 2 attacks defending group 2, killing 32 units
-
-Immune System:
-Group 2 contains 60 units
-Infection:
-Group 1 contains 19 units
-Group 2 contains 182 units
-
-Infection group 1 would deal defending group 2 4408 damage
-Immune System group 2 would deal defending group 1 95700 damage
-Immune System group 2 would deal defending group 2 95700 damage
-
-Immune System group 2 attacks defending group 1, killing 19 units
-
-Immune System:
-Group 2 contains 60 units
-Infection:
-Group 2 contains 182 units
-
-Infection group 2 would deal defending group 2 4368 damage
-Immune System group 2 would deal defending group 2 95700 damage
-
-Infection group 2 attacks defending group 2, killing 3 units
-Immune System group 2 attacks defending group 2, killing 30 units
-
-After a few more fights...
-
-Immune System:
-Group 2 contains 51 units
-Infection:
-Group 2 contains 40 units
-
-Infection group 2 would deal defending group 2 960 damage
-Immune System group 2 would deal defending group 2 81345 damage
-
-Infection group 2 attacks defending group 2, killing 0 units
-Immune System group 2 attacks defending group 2, killing 27 units
-
-Immune System:
-Group 2 contains 51 units
-Infection:
-Group 2 contains 13 units
-
-Infection group 2 would deal defending group 2 312 damage
-Immune System group 2 would deal defending group 2 81345 damage
-
-Infection group 2 attacks defending group 2, killing 0 units
-Immune System group 2 attacks defending group 2, killing 13 units
-
-Immune System:
-Group 2 contains 51 units
-Infection:
-No groups remain.
-
-This boost would allow the immune system's armies to win! It would be left with 51 units.
-
-You don't even know how you could boost the reindeer's immune system or what effect it might have,
-so you need to be cautious and find the smallest boost that would allow the immune system to win.
-
-How many units does the immune system have left after getting the smallest boost it needs to win?
+After careful analysis, one thing is certain: [1m[97myou have no idea where all these bugs are coming
+from[0m.
+
+Then, you remember: Eris is an old Plutonian settlement! Clearly, the bugs are coming from
+recursively-folded space.
+
+This 5x5 grid is [1m[97monly one[0m level in an [1m[97minfinite[0m number of recursion levels. The tile in the middle of
+the grid is actually another 5x5 grid, the grid in your scan is contained as the middle tile of a
+larger 5x5 grid, and so on. Two levels of grids look like this:
+
+ | | | |
+ | | | |
+ | | | |
+-----+-----+---------+-----+-----
+ | | | |
+ | | | |
+ | | | |
+-----+-----+---------+-----+-----
+ | | | | | | | |
+ | |-+-+-+-+-| |
+ | | | | | | | |
+ | |-+-+-+-+-| |
+ | | | |?| | | |
+ | |-+-+-+-+-| |
+ | | | | | | | |
+ | |-+-+-+-+-| |
+ | | | | | | | |
+-----+-----+---------+-----+-----
+ | | | |
+ | | | |
+ | | | |
+-----+-----+---------+-----+-----
+ | | | |
+ | | | |
+ | | | |
+
+(To save space, some of the tiles are not drawn to scale.) Remember, this is only a small part of
+the infinitely recursive grid; there is a 5x5 grid that contains this diagram, and a 5x5 grid that
+contains that one, and so on. Also, the ? in the diagram contains another 5x5 grid, which itself
+contains another 5x5 grid, and so on.
+
+The scan you took (your puzzle input) shows where the bugs are [1m[97mon a single level[0m of this structure.
+The middle tile of your scan is empty to accommodate the recursive grids within it. Initially, no
+other levels contain bugs.
+
+Tiles still count as [1m[97madjacent[0m if they are directly [1m[97mup, down, left, or right[0m of a given tile. Some
+tiles have adjacent tiles at a recursion level above or below its own level. For example:
+
+ | | | |
+ 1 | 2 | 3 | 4 | 5
+ | | | |
+-----+-----+---------+-----+-----
+ | | | |
+ 6 | 7 | 8 | 9 | 10
+ | | | |
+-----+-----+---------+-----+-----
+ | |A|B|C|D|E| |
+ | |-+-+-+-+-| |
+ | |F|G|H|I|J| |
+ | |-+-+-+-+-| |
+ 11 | 12 |K|L|?|N|O| 14 | 15
+ | |-+-+-+-+-| |
+ | |P|Q|R|S|T| |
+ | |-+-+-+-+-| |
+ | |U|V|W|X|Y| |
+-----+-----+---------+-----+-----
+ | | | |
+ 16 | 17 | 18 | 19 | 20
+ | | | |
+-----+-----+---------+-----+-----
+ | | | |
+ 21 | 22 | 23 | 24 | 25
+ | | | |
+
+
+ - Tile 19 has four adjacent tiles: 14, 18, 20, and 24.
+
+ - Tile G has four adjacent tiles: B, F, H, and L.
+
+ - Tile D has four adjacent tiles: 8, C, E, and I.
+
+ - Tile E has four adjacent tiles: 8, D, 14, and J.
+
+ - Tile 14 has [1m[97meight[0m adjacent tiles: 9, E, J, O, T, Y, 15, and 19.
+
+ - Tile N has [1m[97meight[0m adjacent tiles: I, O, S, and five tiles within the sub-grid marked ?.
+
+
+The rules about bugs living and dying are the same as before.
+
+For example, consider the same initial state as above:
+
+....#
+#..#.
+#.?##
+..#..
+#....
+
+The center tile is drawn as ? to indicate the next recursive grid. Call this level 0; the grid
+within this one is level 1, and the grid that contains this one is level -1. Then, after
+[1m[97mten[0m minutes, the grid at each level would look like this:
+
+Depth -5:
+..#..
+.#.#.
+..?.#
+.#.#.
+..#..
+
+Depth -4:
+...#.
+...##
+..?..
+...##
+...#.
+
+Depth -3:
+#.#..
+.#...
+..?..
+.#...
+#.#..
+
+Depth -2:
+.#.##
+....#
+..?.#
+...##
+.###.
+
+Depth -1:
+#..##
+...##
+..?..
+...#.
+.####
+
+Depth 0:
+.#...
+.#.##
+.#?..
+.....
+.....
+
+Depth 1:
+.##..
+#..##
+..?.#
+##.##
+#####
+
+Depth 2:
+###..
+##.#.
+#.?..
+.#.##
+#.#..
+
+Depth 3:
+..###
+.....
+#.?..
+#....
+#...#
+
+Depth 4:
+.###.
+#..#.
+#.?..
+##.#.
+.....
+
+Depth 5:
+####.
+#..#.
+#.?#.
+####.
+.....
+
+In this example, after 10 minutes, a total of [1m[97m99[0m bugs are present.
+
+Starting with your scan, [1m[97mhow many bugs are present after 200 minutes?[0m
diff --git a/25/part1 b/25/part1
@@ -4,13 +4,13 @@ The reindeer's symptoms are getting worse, and neither you nor the white-bearded
solution. At least the reindeer has a warm place to rest: a small bed near where you're sitting.
As you reach down, the reindeer looks up at you, accidentally bumping a button on your wrist-mounted
-device with its nose in the process - a button labeled "help".
+device with its nose in the process - a button labeled [1m[97m"help"[0m.
"Hello, and welcome to the Time Travel Support Hotline! If you are lost in time and space, press 1.
If you are trapped in a time paradox, press 2. If you need help caring for a sick reindeer, press 3.
If you--"
-Beep.
+[1m[97mBeep.[0m
A few seconds later, you hear a new voice. "Hello; please state the nature of your reindeer." You
try to describe the situation.
@@ -26,7 +26,7 @@ forget a mug! Is there anything else I can help you with today?"
You explain that your device isn't capable of going forward in time. "I... see. That's tricky.
Well, according to this information, your device should have the necessary hardware to open a small
-portal and send some hot chocolate back to you. You'll need a list of fixed points in spacetime; I'm
+portal and send some hot chocolate back to you. You'll need a list of [1m[97mfixed points in spacetime[0m; I'm
transmitting it to you now."
"You just need to align your device to the constellations of fixed points so that it can lock on to
@@ -38,9 +38,9 @@ that in the universe! But THAT means that you're--" You disconnect the call.
The list of fixed points in spacetime (your puzzle input) is a set of four-dimensional coordinates.
To align your device, acquire the hot chocolate, and save the reindeer, you just need to find the
-number of constellations of points in the list.
+[1m[97mnumber of constellations[0m of points in the list.
-Two points are in the same constellation if their manhattan distance apart is no more than 3 or if
+Two points are in the same [1m[97mconstellation[0m if their manhattan distance apart is [1m[97mno more than 3[0m or if
they can form a chain of points, each a manhattan distance no more than 3 from the last, between the
two of them. (That is, if a point is close enough to a constellation, it "joins" that
constellation.) For example:
@@ -58,7 +58,7 @@ In the above list, the first six points form a single constellation: 0,0,0,0 is
from the next four, and the point at 0,0,0,6 is connected to the others by being 3 away from
0,0,0,3, which is already in the constellation. The bottom two points, 9,0,0,0 and 12,0,0,0 are in a
separate constellation because no point is close enough to connect them to the first constellation.
-So, in the above list, the number of constellations is 2. (If a point at 6,0,0,0 were present, it
+So, in the above list, the number of constellations is [1m[97m2[0m. (If a point at 6,0,0,0 were present, it
would connect 3,0,0,0 and 9,0,0,0, merging all of the points into a single giant constellation
instead.)
@@ -103,6 +103,6 @@ Finally, in this one, it's 8:
The portly man nervously strokes his white beard. It's time to get that hot chocolate.
-How many constellations are formed by the fixed points in spacetime?
+[1m[97mHow many constellations are formed by the fixed points in spacetime?[0m
diff --git a/25/part2 b/25/part2
@@ -1,15 +1,17 @@
--- Part Two ---
-A small glowing portal opens above the mug you prepared and just enough hot chocolate streams in to
-fill it. You suspect the reindeer has never encountered hot chocolate before, but seems to enjoy it
-anyway. You hope it works.
+As you move through the main airlock, the air inside the ship is already heating up to reasonable
+levels. Santa explains that he didn't notice you coming because he was just taking a quick nap.
+The ship wasn't frozen; he just had the thermostat set to "North Pole".
-It's time to start worrying about that integer underflow in time itself you set up a few days ago.
-You check the status of the device: "Insufficient chronal energy for activation. Energy required: 50
-stars."
+You make your way over to the navigation console. It beeps. "Status: Stranded. Please supply
+measurements from [1m[33m49 stars[0m to recalibrate."
-The reindeer bumps the device with its nose.
+"49 stars? But the Elves told me you needed fifty--"
-"Energy required: 49 stars."
+Santa just smiles and nods his head toward the window. There, in the distance, you can see the
+center of the Solar System: the Sun!
+
+The navigation console beeps again.