Skip to content

Commit 7da5632

Browse files
author
Adrian Reimann
committed
added puzzle.txt to days 1 to 8, and formatted it for day 9 and 10 slightly
1 parent 5551d9c commit 7da5632

File tree

10 files changed

+633
-0
lines changed

10 files changed

+633
-0
lines changed

day_1/puzzle.txt

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
--- Day 1: Sonar Sweep ---
2+
3+
You're minding your own business on a ship at sea when the overboard alarm goes off! You rush to see if you can help. Apparently, one of the Elves tripped and accidentally sent the sleigh keys flying into the ocean!
4+
5+
Before you know it, you're inside a submarine the Elves keep ready for situations like this. It's covered in Christmas lights (because of course it is), and it even has an experimental antenna that should be able to track the keys if you can boost its signal strength high enough; there's a little meter that indicates the antenna's signal strength by displaying 0-50 stars.
6+
7+
Your instincts tell you that in order to save Christmas, you'll need to get all fifty stars by December 25th.
8+
9+
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!
10+
11+
As the submarine drops below the surface of the ocean, it automatically performs a sonar sweep of the nearby sea floor. On a small screen, the sonar sweep report (your puzzle input) appears: each line is a measurement of the sea floor depth as the sweep looks further and further away from the submarine.
12+
13+
For example, suppose you had the following report:
14+
15+
199
16+
200
17+
208
18+
210
19+
200
20+
207
21+
240
22+
269
23+
260
24+
263
25+
26+
This report indicates that, scanning outward from the submarine, the sonar sweep found depths of 199, 200, 208, 210, and so on.
27+
28+
The first order of business is to figure out how quickly the depth increases, just so you know what you're dealing with - you never know if the keys will get carried into deeper water by an ocean current or a fish or something.
29+
30+
To do this, count the number of times a depth measurement increases from the previous measurement. (There is no measurement before the first measurement.) In the example above, the changes are as follows:
31+
32+
199 (N/A - no previous measurement)
33+
200 (increased)
34+
208 (increased)
35+
210 (increased)
36+
200 (decreased)
37+
207 (increased)
38+
240 (increased)
39+
269 (increased)
40+
260 (decreased)
41+
263 (increased)
42+
43+
In this example, there are 7 measurements that are larger than the previous measurement.
44+
45+
How many measurements are larger than the previous measurement?
46+
47+
Your puzzle answer was 1233.
48+
49+
50+
--- Part Two ---
51+
52+
Considering every single measurement isn't as useful as you expected: there's just too much noise in the data.
53+
54+
Instead, consider sums of a three-measurement sliding window. Again considering the above example:
55+
56+
199 A
57+
200 A B
58+
208 A B C
59+
210 B C D
60+
200 E C D
61+
207 E F D
62+
240 E F G
63+
269 F G H
64+
260 G H
65+
263 H
66+
67+
Start by comparing the first and second three-measurement windows. The measurements in the first window are marked A (199, 200, 208); their sum is 199 + 200 + 208 = 607. The second window is marked B (200, 208, 210); its sum is 618. The sum of measurements in the second window is larger than the sum of the first, so this first comparison increased.
68+
69+
Your goal now is to count the number of times the sum of measurements in this sliding window increases from the previous sum. So, compare A with B, then compare B with C, then C with D, and so on. Stop when there aren't enough measurements left to create a new three-measurement sum.
70+
71+
In the above example, the sum of each three-measurement window is as follows:
72+
73+
A: 607 (N/A - no previous sum)
74+
B: 618 (increased)
75+
C: 618 (no change)
76+
D: 617 (decreased)
77+
E: 647 (increased)
78+
F: 716 (increased)
79+
G: 769 (increased)
80+
H: 792 (increased)
81+
82+
In this example, there are 5 sums that are larger than the previous sum.
83+
84+
Consider sums of a three-measurement sliding window. How many sums are larger than the previous sum?
85+
86+
Your puzzle answer was 1275.

day_10/puzzle.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
--- Day 10: Syntax Scoring ---
2+
23
You ask the submarine to determine the best route out of the deep-sea cave, but it only replies:
34

45
Syntax error in navigation subsystem on line: all of them

day_2/puzzle.txt

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--- Day 2: Dive! ---
2+
3+
Now, you need to figure out how to pilot this thing.
4+
5+
It seems like the submarine can take a series of commands like forward 1, down 2, or up 3:
6+
7+
forward X increases the horizontal position by X units.
8+
down X increases the depth by X units.
9+
up X decreases the depth by X units.
10+
Note that since you're on a submarine, down and up affect your depth, and so they have the opposite result of what you might expect.
11+
12+
The submarine seems to already have a planned course (your puzzle input). You should probably figure out where it's going. For example:
13+
14+
forward 5
15+
down 5
16+
forward 8
17+
up 3
18+
down 8
19+
forward 2
20+
21+
Your horizontal position and depth both start at 0. The steps above would then modify them as follows:
22+
23+
forward 5 adds 5 to your horizontal position, a total of 5.
24+
down 5 adds 5 to your depth, resulting in a value of 5.
25+
forward 8 adds 8 to your horizontal position, a total of 13.
26+
up 3 decreases your depth by 3, resulting in a value of 2.
27+
down 8 adds 8 to your depth, resulting in a value of 10.
28+
forward 2 adds 2 to your horizontal position, a total of 15.
29+
30+
After following these instructions, you would have a horizontal position of 15 and a depth of 10. (Multiplying these together produces 150.)
31+
32+
Calculate the horizontal position and depth you would have after following the planned course. What do you get if you multiply your final horizontal position by your final depth?
33+
34+
Your puzzle answer was 1690020.
35+
36+
37+
--- Part Two ---
38+
39+
Based on your calculations, the planned course doesn't seem to make any sense. You find the submarine manual and discover that the process is actually slightly more complicated.
40+
41+
In addition to horizontal position and depth, you'll also need to track a third value, aim, which also starts at 0. The commands also mean something entirely different than you first thought:
42+
43+
down X increases your aim by X units.
44+
up X decreases your aim by X units.
45+
forward X does two things:
46+
It increases your horizontal position by X units.
47+
It increases your depth by your aim multiplied by X.
48+
49+
Again note that since you're on a submarine, down and up do the opposite of what you might expect: "down" means aiming in the positive direction.
50+
51+
Now, the above example does something different:
52+
53+
forward 5 adds 5 to your horizontal position, a total of 5. Because your aim is 0, your depth does not change.
54+
down 5 adds 5 to your aim, resulting in a value of 5.
55+
forward 8 adds 8 to your horizontal position, a total of 13. Because your aim is 5, your depth increases by 8*5=40.
56+
up 3 decreases your aim by 3, resulting in a value of 2.
57+
down 8 adds 8 to your aim, resulting in a value of 10.
58+
forward 2 adds 2 to your horizontal position, a total of 15. Because your aim is 10, your depth increases by 2*10=20 to a total of 60.
59+
60+
After following these new instructions, you would have a horizontal position of 15 and a depth of 60. (Multiplying these produces 900.)
61+
62+
Using this new interpretation of the commands, calculate the horizontal position and depth you would have after following the planned course. What do you get if you multiply your final horizontal position by your final depth?
63+
64+
Your puzzle answer was 1408487760.

day_3/puzzle.txt

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
--- Day 3: Binary Diagnostic ---
2+
3+
The submarine has been making some odd creaking noises, so you ask it to produce a diagnostic report just in case.
4+
5+
The diagnostic report (your puzzle input) consists of a list of binary numbers which, when decoded properly, can tell you many useful things about the conditions of the submarine. The first parameter to check is the power consumption.
6+
7+
You need to use the binary numbers in the diagnostic report to generate two new binary numbers (called the gamma rate and the epsilon rate). The power consumption can then be found by multiplying the gamma rate by the epsilon rate.
8+
9+
Each bit in the gamma rate can be determined by finding the most common bit in the corresponding position of all numbers in the diagnostic report. For example, given the following diagnostic report:
10+
11+
00100
12+
11110
13+
10110
14+
10111
15+
10101
16+
01111
17+
00111
18+
11100
19+
10000
20+
11001
21+
00010
22+
01010
23+
24+
Considering only the first bit of each number, there are five 0 bits and seven 1 bits. Since the most common bit is 1, the first bit of the gamma rate is 1.
25+
26+
The most common second bit of the numbers in the diagnostic report is 0, so the second bit of the gamma rate is 0.
27+
28+
The most common value of the third, fourth, and fifth bits are 1, 1, and 0, respectively, and so the final three bits of the gamma rate are 110.
29+
30+
So, the gamma rate is the binary number 10110, or 22 in decimal.
31+
32+
The epsilon rate is calculated in a similar way; rather than use the most common bit, the least common bit from each position is used. So, the epsilon rate is 01001, or 9 in decimal. Multiplying the gamma rate (22) by the epsilon rate (9) produces the power consumption, 198.
33+
34+
Use the binary numbers in your diagnostic report to calculate the gamma rate and epsilon rate, then multiply them together. What is the power consumption of the submarine? (Be sure to represent your answer in decimal, not binary.)
35+
36+
Your puzzle answer was 4174964.
37+
38+
39+
--- Part Two ---
40+
41+
Next, you should verify the life support rating, which can be determined by multiplying the oxygen generator rating by the CO2 scrubber rating.
42+
43+
Both the oxygen generator rating and the CO2 scrubber rating are values that can be found in your diagnostic report - finding them is the tricky part. Both values are located using a similar process that involves filtering out values until only one remains. Before searching for either rating value, start with the full list of binary numbers from your diagnostic report and consider just the first bit of those numbers. Then:
44+
45+
Keep only numbers selected by the bit criteria for the type of rating value for which you are searching. Discard numbers which do not match the bit criteria.
46+
If you only have one number left, stop; this is the rating value for which you are searching.
47+
Otherwise, repeat the process, considering the next bit to the right.
48+
49+
The bit criteria depends on which type of rating value you want to find:
50+
51+
To find oxygen generator rating, determine the most common value (0 or 1) in the current bit position, and keep only numbers with that bit in that position. If 0 and 1 are equally common, keep values with a 1 in the position being considered.
52+
To find CO2 scrubber rating, determine the least common value (0 or 1) in the current bit position, and keep only numbers with that bit in that position. If 0 and 1 are equally common, keep values with a 0 in the position being considered.
53+
54+
For example, to determine the oxygen generator rating value using the same example diagnostic report from above:
55+
56+
Start with all 12 numbers and consider only the first bit of each number. There are more 1 bits (7) than 0 bits (5), so keep only the 7 numbers with a 1 in the first position: 11110, 10110, 10111, 10101, 11100, 10000, and 11001.
57+
Then, consider the second bit of the 7 remaining numbers: there are more 0 bits (4) than 1 bits (3), so keep only the 4 numbers with a 0 in the second position: 10110, 10111, 10101, and 10000.
58+
In the third position, three of the four numbers have a 1, so keep those three: 10110, 10111, and 10101.
59+
In the fourth position, two of the three numbers have a 1, so keep those two: 10110 and 10111.
60+
In the fifth position, there are an equal number of 0 bits and 1 bits (one each). So, to find the oxygen generator rating, keep the number with a 1 in that position: 10111.
61+
As there is only one number left, stop; the oxygen generator rating is 10111, or 23 in decimal.
62+
63+
Then, to determine the CO2 scrubber rating value from the same example above:
64+
65+
Start again with all 12 numbers and consider only the first bit of each number. There are fewer 0 bits (5) than 1 bits (7), so keep only the 5 numbers with a 0 in the first position: 00100, 01111, 00111, 00010, and 01010.
66+
Then, consider the second bit of the 5 remaining numbers: there are fewer 1 bits (2) than 0 bits (3), so keep only the 2 numbers with a 1 in the second position: 01111 and 01010.
67+
In the third position, there are an equal number of 0 bits and 1 bits (one each). So, to find the CO2 scrubber rating, keep the number with a 0 in that position: 01010.
68+
As there is only one number left, stop; the CO2 scrubber rating is 01010, or 10 in decimal.
69+
70+
Finally, to find the life support rating, multiply the oxygen generator rating (23) by the CO2 scrubber rating (10) to get 230.
71+
72+
Use the binary numbers in your diagnostic report to calculate the oxygen generator rating and CO2 scrubber rating, then multiply them together. What is the life support rating of the submarine? (Be sure to represent your answer in decimal, not binary.)
73+
74+
Your puzzle answer was 4474944.

day_4/puzzle.txt

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
--- Day 4: Giant Squid ---
2+
3+
You're already almost 1.5km (almost a mile) below the surface of the ocean, already so deep that you can't see any sunlight. What you can see, however, is a giant squid that has attached itself to the outside of your submarine.
4+
5+
Maybe it wants to play bingo?
6+
7+
Bingo is played on a set of boards each consisting of a 5x5 grid of numbers. Numbers are chosen at random, and the chosen number is marked on all boards on which it appears. (Numbers may not appear on all boards.) If all numbers in any row or any column of a board are marked, that board wins. (Diagonals don't count.)
8+
9+
The submarine has a bingo subsystem to help passengers (currently, you and the giant squid) pass the time. It automatically generates a random order in which to draw numbers and a random set of boards (your puzzle input). For example:
10+
11+
7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1
12+
13+
22 13 17 11 0
14+
8 2 23 4 24
15+
21 9 14 16 7
16+
6 10 3 18 5
17+
1 12 20 15 19
18+
19+
3 15 0 2 22
20+
9 18 13 17 5
21+
19 8 7 25 23
22+
20 11 10 24 4
23+
14 21 16 12 6
24+
25+
14 21 17 24 4
26+
10 16 15 9 19
27+
18 8 23 26 20
28+
22 11 13 6 5
29+
2 0 12 3 7
30+
31+
After the first five numbers are drawn (7, 4, 9, 5, and 11), there are no winners, but the boards are marked as follows (shown here adjacent to each other to save space):
32+
33+
22 13 17 11 0 3 15 0 2 22 14 21 17 24 4
34+
8 2 23 4 24 9 18 13 17 5 10 16 15 9 19
35+
21 9 14 16 7 19 8 7 25 23 18 8 23 26 20
36+
6 10 3 18 5 20 11 10 24 4 22 11 13 6 5
37+
1 12 20 15 19 14 21 16 12 6 2 0 12 3 7
38+
39+
After the next six numbers are drawn (17, 23, 2, 0, 14, and 21), there are still no winners:
40+
41+
22 13 17 11 0 3 15 0 2 22 14 21 17 24 4
42+
8 2 23 4 24 9 18 13 17 5 10 16 15 9 19
43+
21 9 14 16 7 19 8 7 25 23 18 8 23 26 20
44+
6 10 3 18 5 20 11 10 24 4 22 11 13 6 5
45+
1 12 20 15 19 14 21 16 12 6 2 0 12 3 7
46+
47+
Finally, 24 is drawn:
48+
49+
22 13 17 11 0 3 15 0 2 22 14 21 17 24 4
50+
8 2 23 4 24 9 18 13 17 5 10 16 15 9 19
51+
21 9 14 16 7 19 8 7 25 23 18 8 23 26 20
52+
6 10 3 18 5 20 11 10 24 4 22 11 13 6 5
53+
1 12 20 15 19 14 21 16 12 6 2 0 12 3 7
54+
55+
At this point, the third board wins because it has at least one complete row or column of marked numbers (in this case, the entire top row is marked: 14 21 17 24 4).
56+
57+
The score of the winning board can now be calculated. Start by finding the sum of all unmarked numbers on that board; in this case, the sum is 188. Then, multiply that sum by the number that was just called when the board won, 24, to get the final score, 188 * 24 = 4512.
58+
59+
To guarantee victory against the giant squid, figure out which board will win first. What will your final score be if you choose that board?
60+
61+
Your puzzle answer was 39984.
62+
63+
64+
--- Part Two ---
65+
66+
On the other hand, it might be wise to try a different strategy: let the giant squid win.
67+
68+
You aren't sure how many bingo boards a giant squid could play at once, so rather than waste time counting its arms, the safe thing to do is to figure out which board will win last and choose that one. That way, no matter which boards it picks, it will win for sure.
69+
70+
In the above example, the second board is the last to win, which happens after 13 is eventually called and its middle column is completely marked. If you were to keep playing until this point, the second board would have a sum of unmarked numbers equal to 148 for a final score of 148 * 13 = 1924.
71+
72+
Figure out which board will win last. Once it wins, what would its final score be?
73+
74+
Your puzzle answer was 8468.

day_5/puzzle.txt

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
--- Day 5: Hydrothermal Venture ---
2+
3+
You come across a field of hydrothermal vents on the ocean floor! These vents constantly produce large, opaque clouds, so it would be best to avoid them if possible.
4+
5+
They tend to form in lines; the submarine helpfully produces a list of nearby lines of vents (your puzzle input) for you to review. For example:
6+
7+
0,9 -> 5,9
8+
8,0 -> 0,8
9+
9,4 -> 3,4
10+
2,2 -> 2,1
11+
7,0 -> 7,4
12+
6,4 -> 2,0
13+
0,9 -> 2,9
14+
3,4 -> 1,4
15+
0,0 -> 8,8
16+
5,5 -> 8,2
17+
18+
Each line of vents is given as a line segment in the format x1,y1 -> x2,y2 where x1,y1 are the coordinates of one end the line segment and x2,y2 are the coordinates of the other end. These line segments include the points at both ends. In other words:
19+
20+
An entry like 1,1 -> 1,3 covers points 1,1, 1,2, and 1,3.
21+
An entry like 9,7 -> 7,7 covers points 9,7, 8,7, and 7,7.
22+
23+
For now, only consider horizontal and vertical lines: lines where either x1 = x2 or y1 = y2.
24+
25+
So, the horizontal and vertical lines from the above list would produce the following diagram:
26+
27+
.......1..
28+
..1....1..
29+
..1....1..
30+
.......1..
31+
.112111211
32+
..........
33+
..........
34+
..........
35+
..........
36+
222111....
37+
38+
In this diagram, the top left corner is 0,0 and the bottom right corner is 9,9. Each position is shown as the number of lines which cover that point or . if no line covers that point. The top-left pair of 1s, for example, comes from 2,2 -> 2,1; the very bottom row is formed by the overlapping lines 0,9 -> 5,9 and 0,9 -> 2,9.
39+
40+
To avoid the most dangerous areas, you need to determine the number of points where at least two lines overlap. In the above example, this is anywhere in the diagram with a 2 or larger - a total of 5 points.
41+
42+
Consider only horizontal and vertical lines. At how many points do at least two lines overlap?
43+
44+
Your puzzle answer was 5576.
45+
46+
47+
--- Part Two ---
48+
49+
Unfortunately, considering only horizontal and vertical lines doesn't give you the full picture; you need to also consider diagonal lines.
50+
51+
Because of the limits of the hydrothermal vent mapping system, the lines in your list will only ever be horizontal, vertical, or a diagonal line at exactly 45 degrees. In other words:
52+
53+
An entry like 1,1 -> 3,3 covers points 1,1, 2,2, and 3,3.
54+
An entry like 9,7 -> 7,9 covers points 9,7, 8,8, and 7,9.
55+
56+
Considering all lines from the above example would now produce the following diagram:
57+
58+
1.1....11.
59+
.111...2..
60+
..2.1.111.
61+
...1.2.2..
62+
.112313211
63+
...1.2....
64+
..1...1...
65+
.1.....1..
66+
1.......1.
67+
222111....
68+
69+
You still need to determine the number of points where at least two lines overlap. In the above example, this is still anywhere in the diagram with a 2 or larger - now a total of 12 points.
70+
71+
Consider all of the lines. At how many points do at least two lines overlap?
72+
73+
Your puzzle answer was 18144.

0 commit comments

Comments
 (0)