Skip to content

Commit a75f105

Browse files
committed
Added answers to descriptions
Refactored utils.js
1 parent ffb2050 commit a75f105

35 files changed

+160
-59
lines changed

day1/description.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ For example:
2121
What is the solution to your captcha?
2222

2323

24+
Your puzzle answer was 1223.
25+
26+
2427
--- Part Two ---
2528

2629
You notice a progress bar that jumps to 50% completion. Apparently, the door isn't yet satisfied, but it did emit a star as encouragement. The instructions change:
@@ -34,4 +37,7 @@ For example:
3437
123425 produces 4, because both 2s match each other, but no other digit has a match.
3538
123123 produces 12.
3639
12131415 produces 4.
37-
What is the solution to your new captcha?
40+
What is the solution to your new captcha?
41+
42+
43+
Your puzzle answer was 1284.

day1/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#!/usr/bin/env node
2-
const { getInput } = require('../utils');
2+
const { getRow } = require('../utils');
33
const { sum } = require('./sum');
44

5-
getInput()
5+
getRow()
66
.then((data) => {
7-
const input = data[0];
8-
9-
console.log(`Part 1: ${sum(input)}`);
10-
console.log(`Part 2: ${sum(input, true)}`);
7+
console.log(`Part 1: ${sum(data)}`);
8+
console.log(`Part 2: ${sum(data, true)}`);
119
})
1210
.catch(err => console.log(`There was an error\n${err}`));

day10/description.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ In this example, the first two numbers in the list end up being 3 and 4; to chec
3535

3636
However, you should instead use the standard list size of 256 (with values 0 to 255) and the sequence of lengths in your puzzle input. Once this process is complete, what is the result of multiplying the first two numbers in the list?
3737

38+
39+
Your puzzle answer was 54675.
40+
41+
3842
--- Part Two ---
3943

4044
The logic you've constructed forms a single round of the Knot Hash algorithm; running the full thing requires many of these rounds. Some input and output processing is also required.
@@ -60,4 +64,7 @@ The empty string becomes a2582a3a0e66e6e86e3812dcb672a272.
6064
AoC 2017 becomes 33efeb34ea91902bb2f59c9920caa6cd.
6165
1,2,3 becomes 3efbe78a8d82f29979031a4aa0b16a9d.
6266
1,2,4 becomes 63960835bcdc130f0b66d7ff4f6a5a8e.
63-
Treating your puzzle input as a string of ASCII characters, what is the Knot Hash of your puzzle input? Ignore any leading or trailing whitespace you might encounter.
67+
Treating your puzzle input as a string of ASCII characters, what is the Knot Hash of your puzzle input? Ignore any leading or trailing whitespace you might encounter.
68+
69+
70+
Your puzzle answer was a7af2706aa9a09cf5d848c1e6605dd2a.

day10/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/usr/bin/env node
2-
const { applyLengths, getInput, hashString } = require('../utils');
2+
const { applyLengths, getRow, hashString } = require('../utils');
33

44

55
const listSize = 256;
66

77

8-
getInput()
8+
getRow()
99
.then((data) => {
1010

1111
const part1 = () => {
1212
const list = [...Array(listSize).keys()];
13-
const lengths = data[0]
13+
const lengths = data
1414
.split(',')
1515
.map(char => parseInt(char, 10));
1616

@@ -19,7 +19,7 @@ getInput()
1919
};
2020

2121
const part2 = () => {
22-
console.log(hashString(data[0]));
22+
console.log(hashString(data));
2323
};
2424

2525
part1();

day11/description.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ ne,ne,sw,sw is 0 steps away (back where you started).
2424
ne,ne,s,s is 2 steps away (se,se).
2525
se,sw,se,sw,sw is 3 steps away (s,s,sw).
2626

27+
28+
Your puzzle answer was 720.
29+
30+
2731
--- Part Two ---
2832

2933
How many steps away is the furthest he ever got from his starting position?
3034

35+
36+
Your puzzle answer was 1485.
37+

day11/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
/* eslint no-param-reassign: 0 */
3-
const { getInput } = require('../utils');
3+
const { getRow } = require('../utils');
44

55
const hexDirections = {
66
n: { x: 0, y: 1 },
@@ -18,13 +18,13 @@ const manhattanDistanceHex = ({ x, y }) => {
1818
return Math.max(Math.abs(x), Math.abs(y));
1919
};
2020

21-
getInput()
21+
getRow()
2222
.then((data) => {
2323

2424
let maxDistance = 0;
2525
let currentDistance = 0;
2626

27-
data[0]
27+
data
2828
.split(',')
2929
.map(step => hexDirections[step])
3030
.reduce((totalSteps, distance) => {

day12/description.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Therefore, a total of 6 programs are in this group; all but program 1, which has
3131

3232
How many programs are in the group that contains program ID 0?
3333

34+
35+
Your puzzle answer was 378.
36+
37+
3438
--- Part Two ---
3539

3640
There are more programs than just the ones in the group containing program ID 0. The rest of them have no way of reaching that group, and still might have no way of reaching each other.

day12/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
2-
const { getInput } = require('../utils');
2+
const { getRows } = require('../utils');
33

4-
getInput()
4+
getRows()
55
.then((data) => {
66

77
const programs = data

day13/description.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ The severity of getting caught on a layer is equal to its depth multiplied by it
158158

159159
Given the details of the firewall you've recorded, if you leave immediately, what is the severity of your whole trip?
160160

161+
162+
Your puzzle answer was 1960.
163+
164+
161165
--- Part Two ---
162166

163167
Now, you need to pass through the firewall without being caught - easier said than done.
@@ -271,4 +275,7 @@ Picosecond 16:
271275
[ ] [ ]
272276
Because all smaller delays would get you caught, the fewest number of picoseconds you would need to delay to get through safely is 10.
273277

274-
What is the fewest number of picoseconds that you need to delay the packet to pass through the firewall without being caught?
278+
What is the fewest number of picoseconds that you need to delay the packet to pass through the firewall without being caught?
279+
280+
281+
Your puzzle answer was 3903378.

day13/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22
/* eslint no-param-reassign: 0 */
3-
const { getInput } = require('../utils');
3+
const { getRows } = require('../utils');
44

5-
getInput()
5+
getRows()
66
.then((data) => {
77
const input = data.map((row) => {
88
const [depth, range] = row.split(': ');

0 commit comments

Comments
 (0)