Skip to content

Commit dd5d94c

Browse files
feat(2020-day-10): find the voltage differences to solve for part 1
1 parent 308ddca commit dd5d94c

File tree

2 files changed

+98
-3
lines changed

2 files changed

+98
-3
lines changed

2020/day-10/input.txt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
47
2+
99
3+
115
4+
65
5+
10
6+
55
7+
19
8+
73
9+
80
10+
100
11+
71
12+
110
13+
64
14+
135
15+
49
16+
3
17+
1
18+
98
19+
132
20+
2
21+
38
22+
118
23+
66
24+
116
25+
104
26+
87
27+
79
28+
114
29+
40
30+
37
31+
44
32+
97
33+
4
34+
140
35+
60
36+
86
37+
56
38+
133
39+
7
40+
146
41+
85
42+
111
43+
134
44+
53
45+
121
46+
77
47+
117
48+
21
49+
12
50+
81
51+
145
52+
129
53+
107
54+
93
55+
22
56+
48
57+
11
58+
54
59+
92
60+
78
61+
67
62+
20
63+
138
64+
125
65+
57
66+
96
67+
26
68+
147
69+
124
70+
34
71+
74
72+
143
73+
13
74+
28
75+
126
76+
50
77+
29
78+
70
79+
39
80+
63
81+
41
82+
91
83+
32
84+
84
85+
144
86+
27
87+
139
88+
33
89+
88
90+
72
91+
23
92+
103
93+
16

2020/day-10/solution.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
const { count } = require('console')
12
const fs = require('fs')
23
const path = require('path')
34
const filePath = path.join(__dirname, 'input.txt')
45
const { inputToArray } = require('../../2018/inputParser')
6+
const { countDifferences } = require('./jolts')
57

68
fs.readFile(filePath, { encoding: 'utf8' }, (err, initData) => {
79
if (err) throw err
810

9-
initData = inputToArray(initData.trim())
11+
initData = inputToArray(initData.trim()).map(Number)
1012

1113
const resetInput = () => {
1214
// Deep copy to ensure we aren't mutating the original data
@@ -15,8 +17,8 @@ fs.readFile(filePath, { encoding: 'utf8' }, (err, initData) => {
1517

1618
const part1 = () => {
1719
const data = resetInput()
18-
console.debug(data)
19-
return 'No answer yet'
20+
const differences = countDifferences(data)
21+
return differences[1] * differences[3]
2022
}
2123

2224
const part2 = () => {

0 commit comments

Comments
 (0)