Skip to content

Commit 80635fe

Browse files
committed
docs: add readme files
1 parent 239dbf9 commit 80635fe

File tree

9 files changed

+264
-0
lines changed

9 files changed

+264
-0
lines changed

day_05/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,17 @@ These have middle page numbers of `61`, `53`, and `29` respectively. Adding thes
8484
Of course, you'll need to be careful: the actual list of _page ordering rules_ is bigger and more complicated than the above example.
8585

8686
Determine which updates are already in the correct order. _What do you get if you add up the middle page number from those correctly-ordered updates?_
87+
88+
### Part Two
89+
90+
While the Elves get to work printing the correctly-ordered updates, you have a little time to fix the rest of them.
91+
92+
For each of the _incorrectly-ordered updates_, use the page ordering rules to put the page numbers in the right order. For the above example, here are the three incorrectly-ordered updates and their correct orderings:
93+
94+
* `75,97,47,61,53` becomes `97,75,47,61,53`.
95+
* `61,13,29` becomes `61,29,13`.
96+
* `97,13,75,29,47` becomes `97,75,47,29,13`.
97+
98+
After taking _only the incorrectly-ordered updates_ and ordering them correctly, their middle page numbers are `47`, `29`, and `47`. Adding these together produces _`123`_.
99+
100+
Find the updates which are not in the correct order. _What do you get if you add up the middle page numbers after correctly ordering just those updates?_

day_07/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,19 @@ Only three of the above equations can be made true by inserting operators:
3838
The engineers just need the _total calibration result_, which is the sum of the test values from just the equations that could possibly be true. In the above example, the sum of the test values for the three equations listed above is _`3749`_.
3939

4040
Determine which equations could possibly be true. _What is their total calibration result?_
41+
42+
### Part Two
43+
44+
The engineers seem concerned; the total calibration result you gave them is nowhere close to being within safety tolerances. Just then, you spot your mistake: some well-hidden elephants are holding a _third type of operator_.
45+
46+
The [concatenation](https://en.wikipedia.org/wiki/Concatenation) operator (`<span title="I think you mean &quot;.&quot;.">||</span>`) combines the digits from its left and right inputs into a single number. For example, `12 || 345` would become `12345`. All operators are still evaluated left-to-right.
47+
48+
Now, apart from the three equations that could be made true using only addition and multiplication, the above example has three more equations that can be made true by inserting operators:
49+
50+
* `156: 15 6` can be made true through a single concatenation: `15 || 6 = 156`.
51+
* `7290: 6 8 6 15` can be made true using `6 * 8 || 6 * 15`.
52+
* `192: 17 8 14` can be made true using `17 || 8 + 14`.
53+
54+
Adding up all six test values (the three that could be made before using only `+` and `*` plus the new three that can now be made by also using `||`) produces the new _total calibration result_ of _`11387`_.
55+
56+
Using your new knowledge of elephant hiding spots, determine which equations could possibly be true. _What is their total calibration result?_

day_09/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,24 @@ The final step of this file-compacting process is to update the _filesystem chec
5858
Continuing the first example, the first few blocks' position multiplied by its file ID number are `0 * 0 = 0`, `1 * 0 = 0`, `2 * 9 = 18`, `3 * 9 = 27`, `4 * 8 = 32`, and so on. In this example, the checksum is the sum of these, _`1928`_.
5959

6060
<span title="Bonus points if you make a cool animation of this process.">Compact the amphipod's hard drive</span> using the process he requested. _What is the resulting filesystem checksum?_ <span class="quiet">(Be careful copy/pasting the input for this puzzle; it is a single, very long line.)</span>
61+
62+
### Part Two
63+
64+
Upon completion, two things immediately become clear. First, the disk definitely has a lot more contiguous free space, just like the amphipod hoped. Second, the computer is running much more slowly! Maybe introducing all of that [file system fragmentation](https://en.wikipedia.org/wiki/File_system_fragmentation) was a bad idea?
65+
66+
The eager amphipod already has a new plan: rather than move individual blocks, he'd like to try compacting the files on his disk by moving _whole files_ instead.
67+
68+
This time, attempt to move whole files to the leftmost span of free space blocks that could fit the file. Attempt to move each file exactly once in order of _decreasing file ID number_ starting with the file with the highest file ID number. If there is no span of free space to the left of a file that is large enough to fit the file, the file does not move.
69+
70+
The first example from above now proceeds differently:
71+
72+
00...111...2...333.44.5555.6666.777.888899
73+
0099.111...2...333.44.5555.6666.777.8888..
74+
0099.1117772...333.44.5555.6666.....8888..
75+
0099.111777244.333....5555.6666.....8888..
76+
00992111777.44.333....5555.6666.....8888..
77+
78+
79+
The process of updating the filesystem checksum is the same; now, this example's checksum would be _`2858`_.
80+
81+
Start over, now compacting the amphipod's hard drive using this new method instead. _What is the resulting filesystem checksum?_

day_10/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,66 @@ Here's a larger example:
7676
This larger example has 9 trailheads. Considering the trailheads in reading order, they have scores of `5`, `6`, `5`, `3`, `1`, `3`, `5`, `3`, and `5`. Adding these scores together, the sum of the scores of all trailheads is _`36`_.
7777

7878
The reindeer gleefully carries over a protractor and adds it to the pile. _What is the sum of the scores of all trailheads on your topographic map?_
79+
80+
### Part Two
81+
82+
The reindeer spends a few minutes reviewing your hiking trail map before realizing something, disappearing for a few minutes, and finally returning with yet another slightly-charred piece of paper.
83+
84+
The paper describes a second way to measure a trailhead called its _rating_. A trailhead's rating is the _number of distinct hiking trails_ which begin at that trailhead. For example:
85+
86+
.....0.
87+
..4321.
88+
..5..2.
89+
..6543.
90+
..7..4.
91+
..8765.
92+
..9....
93+
94+
95+
The above map has a single trailhead; its rating is `3` because there are exactly three distinct hiking trails which begin at that position:
96+
97+
.....0. .....0. .....0.
98+
..4321. .....1. .....1.
99+
..5.... .....2. .....2.
100+
..6.... ..6543. .....3.
101+
..7.... ..7.... .....4.
102+
..8.... ..8.... ..8765.
103+
..9.... ..9.... ..9....
104+
105+
106+
Here is a map containing a single trailhead with rating `13`:
107+
108+
..90..9
109+
...1.98
110+
...2..7
111+
6543456
112+
765.987
113+
876....
114+
987....
115+
116+
117+
This map contains a single trailhead with rating `227` (because there are `121` distinct hiking trails that lead to the `9` on the right edge and `106` that lead to the `9` on the bottom edge):
118+
119+
012345
120+
123456
121+
234567
122+
345678
123+
4.6789
124+
56789.
125+
126+
127+
Here's the larger example from before:
128+
129+
89010123
130+
78121874
131+
87430965
132+
96549874
133+
45678903
134+
32019012
135+
01329801
136+
10456732
137+
138+
139+
Considering its trailheads in reading order, they have ratings of `20`, `24`, `10`, `4`, `1`, `4`, `5`, `8`, and `5`. The sum of all trailhead ratings in this larger example topographic map is _`81`_.
140+
141+
You're not sure how, but the reindeer seems to have crafted some tiny flags out of toothpicks and bits of paper and is using them to mark trailheads on your topographic map. _What is the sum of the ratings of all trailheads?_

day_11/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ Here is a longer example:
6161
In this example, after blinking six times, you would have `22` stones. After blinking 25 times, you would have _`55312`_ stones!
6262

6363
Consider the arrangement of stones in front of you. _How many stones will you have after blinking 25 times?_
64+
65+
### Part Two
66+
67+
The Historians sure are taking a long time. To be fair, the infinite corridors _are_ very large.
68+
69+
_How many stones would you have after blinking a total of 75 times?_

day_12/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,64 @@ It contains:
9393
So, it has a total price of _`1930`_.
9494

9595
_What is the total price of fencing all regions on your map?_
96+
97+
### Part Two
98+
99+
Fortunately, the Elves are trying to order so much fence that they qualify for a _bulk discount_!
100+
101+
Under the bulk discount, instead of using the perimeter to calculate the price, you need to use the _number of sides_ each region has. Each straight section of fence counts as a side, regardless of how long it is.
102+
103+
Consider this example again:
104+
105+
AAAA
106+
BBCD
107+
BBCC
108+
EEEC
109+
110+
111+
The region containing type `A` plants has `4` sides, as does each of the regions containing plants of type `B`, `D`, and `E`. However, the more complex region containing the plants of type `C` has `8` sides!
112+
113+
Using the new method of calculating the per-region price by multiplying the region's area by its number of sides, regions `A` through `E` have prices `16`, `16`, `32`, `4`, and `12`, respectively, for a total price of _`80`_.
114+
115+
The second example above (full of type `X` and `O` plants) would have a total price of _`436`_.
116+
117+
Here's a map that includes an E-shaped region full of type `E` plants:
118+
119+
EEEEE
120+
EXXXX
121+
EEEEE
122+
EXXXX
123+
EEEEE
124+
125+
126+
The E-shaped region has an area of `17` and `12` sides for a price of `204`. Including the two regions full of type `X` plants, this map has a total price of _`236`_.
127+
128+
This map has a total price of _`368`_:
129+
130+
AAAAAA
131+
AAABBA
132+
AAABBA
133+
ABBAAA
134+
ABBAAA
135+
AAAAAA
136+
137+
138+
It includes two regions full of type `B` plants (each with `4` sides) and a single region full of type `A` plants (with `4` sides on the outside and `8` more sides on the inside, a total of `12` sides). Be especially careful when counting the fence around regions like the one full of type `A` plants; in particular, each section of fence has an in-side and an out-side, so the fence does not connect across the middle of the region (where the two `B` regions touch diagonally). (The Elves would have used the Möbius Fencing Company instead, but their contract terms were too one-sided.)
139+
140+
The larger example from before now has the following updated prices:
141+
142+
* A region of `R` plants with price `12 * 10 = 120`.
143+
* A region of `I` plants with price `4 * 4 = 16`.
144+
* A region of `C` plants with price `14 * 22 = 308`.
145+
* A region of `F` plants with price `10 * 12 = 120`.
146+
* A region of `V` plants with price `13 * 10 = 130`.
147+
* A region of `J` plants with price `11 * 12 = 132`.
148+
* A region of `C` plants with price `1 * 4 = 4`.
149+
* A region of `E` plants with price `13 * 8 = 104`.
150+
* A region of `I` plants with price `14 * 16 = 224`.
151+
* A region of `M` plants with price `5 * 6 = 30`.
152+
* A region of `S` plants with price `3 * 6 = 18`.
153+
154+
Adding these together produces its new total price of _`1206`_.
155+
156+
_What is the new total price of fencing all regions on your map?_

day_13/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,30 @@ So, the most prizes you could possibly win is two; the minimum tokens you would
5454
You estimate that each button would need to be pressed _no more than `100` times_ to win a prize. How else would someone be expected to play?
5555

5656
Figure out how to win as many prizes as possible. _What is the fewest tokens you would have to spend to win all possible prizes?_
57+
58+
### Part Two
59+
60+
As you go to win the first prize, you discover that the claw is nowhere near where you expected it would be. Due to a unit conversion error in your measurements, the position of every prize is actually `10000000000000` higher on both the `X` and `Y` axis!
61+
62+
Add `10000000000000` to the `X` and `Y` position of every prize. After making this change, the example above would now look like this:
63+
64+
Button A: X+94, Y+34
65+
Button B: X+22, Y+67
66+
Prize: X=10000000008400, Y=10000000005400
67+
68+
Button A: X+26, Y+66
69+
Button B: X+67, Y+21
70+
Prize: X=10000000012748, Y=10000000012176
71+
72+
Button A: X+17, Y+86
73+
Button B: X+84, Y+37
74+
Prize: X=10000000007870, Y=10000000006450
75+
76+
Button A: X+69, Y+23
77+
Button B: X+27, Y+71
78+
Prize: X=10000000018641, Y=10000000010279
79+
80+
81+
Now, it is only possible to win a prize on the second and fourth claw machines. Unfortunately, it will take _many more than `100` presses_ to do so.
82+
83+
Using the corrected prize coordinates, figure out how to win as many prizes as possible. _What is the fewest tokens you would have to spend to win all possible prizes?_

day_14/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,9 @@ To determine the safest area, count the _number of robots in each quadrant_ afte
129129
In this example, the quadrants contain `1`, `3`, `4`, and `1` robot. Multiplying these together gives a total _safety factor_ of _`12`_.
130130

131131
Predict the motion of the robots in your list within a space which is `101` tiles wide and `103` tiles tall. _What will the safety factor be after exactly 100 seconds have elapsed?_
132+
133+
### Part Two
134+
135+
During the bathroom break, someone notices that these robots seem awfully similar to ones built and used at the North Pole. If they're the same type of robots, they should have a hard-coded <span title="This puzzle was originally going to be about the motion of space rocks in a fictitious arcade game called Meteoroids, but we just had an arcade puzzle.">Easter egg</span>: very rarely, most of the robots should arrange themselves into _a picture of a Christmas tree_.
136+
137+
_What is the fewest number of seconds that must elapse for the robots to display the Easter egg?_

day_16/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,53 @@ In this maze, the best paths cost _`11048`_ points; following one such path woul
9696
Note that the path shown above includes one 90 degree turn as the very first move, rotating the Reindeer from facing East to facing North.
9797

9898
Analyze your map carefully. _What is the lowest score a Reindeer could possibly get?_
99+
100+
### Part Two
101+
102+
Now that you know what the best paths look like, you can figure out the best spot to sit.
103+
104+
Every non-wall tile (`S`, `.`, or `E`) is equipped with places to sit along the edges of the tile. While determining which of these tiles would be the best spot to sit depends on a whole bunch of factors (how comfortable the seats are, how far away the bathrooms are, whether there's a pillar blocking your view, etc.), the most important factor is _whether the tile is on one of the best paths through the maze_. If you sit somewhere else, you'd miss all the action!
105+
106+
So, you'll need to determine which tiles are part of _any_ best path through the maze, including the `S` and `E` tiles.
107+
108+
In the first example, there are _`45`_ tiles (marked `O`) that are part of at least one of the various best paths through the maze:
109+
110+
###############
111+
#.......#....O#
112+
#.#.###.#.###O#
113+
#.....#.#...#O#
114+
#.###.#####.#O#
115+
#.#.#.......#O#
116+
#.#.#####.###O#
117+
#..OOOOOOOOO#O#
118+
###O#O#####O#O#
119+
#OOO#O....#O#O#
120+
#O#O#O###.#O#O#
121+
#OOOOO#...#O#O#
122+
#O###.#.#.#O#O#
123+
#O..#.....#OOO#
124+
###############
125+
126+
127+
In the second example, there are _`64`_ tiles that are part of at least one of the best paths:
128+
129+
#################
130+
#...#...#...#..O#
131+
#.#.#.#.#.#.#.#O#
132+
#.#.#.#...#...#O#
133+
#.#.#.#.###.#.#O#
134+
#OOO#.#.#.....#O#
135+
#O#O#.#.#.#####O#
136+
#O#O..#.#.#OOOOO#
137+
#O#O#####.#O###O#
138+
#O#O#..OOOOO#OOO#
139+
#O#O###O#####O###
140+
#O#O#OOO#..OOO#.#
141+
#O#O#O#####O###.#
142+
#O#O#OOOOOOO..#.#
143+
#O#O#O#########.#
144+
#O#OOO..........#
145+
#################
146+
147+
148+
Analyze your map further. _How many tiles are part of at least one of the best paths through the maze?_

0 commit comments

Comments
 (0)