Skip to content

Commit 4c83149

Browse files
committed
day3
1 parent 6ff5126 commit 4c83149

File tree

6 files changed

+702
-1
lines changed

6 files changed

+702
-1
lines changed

bin/adventofcode2020

276 Bytes
Binary file not shown.

bin/inputs/day3.txt

Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
....#.#..#.#.#.#......#....##.#
2+
..##..#.#..#.##.....#.....#....
3+
....#..#...#..#..####.##.#.##..
4+
...............#.....##..##..#.
5+
##...####..##.#..#...####...#.#
6+
..#.#....##....##.........#...#
7+
.#..#.##..............#.....###
8+
##..##..#.....#..#...#....#....
9+
.#.........#..#...#.#.#.....#..
10+
......#...#..#.##..#.....#.#...
11+
.#...#.#.#.##.##.....###...#...
12+
..........#.......#...#....#..#
13+
.....##..#.#...#...##.##.......
14+
...#.###.#.#..##...#.#.........
15+
###.###....#...###.#.##...#....
16+
...........#....#.....##....###
17+
#..#.......#.....#.....##....#.
18+
.##.#....#...#....#......#..##.
19+
..#....#..#..#......#..........
20+
#..#.........#.#....#.##...#.#.
21+
#....#.#.......#.#.#.#.......#.
22+
.#....#....#..##.##.#....#.#...
23+
............#....#.#.#........#
24+
#..#..#.....#....#.##.##.#....#
25+
....#......#..##..#....#...#...
26+
.............#.##....####...##.
27+
#.##..##..##.#.....#...........
28+
#.#...#......####.##..#.#......
29+
.......#.#..#...#.#.###.......#
30+
#..#..........#...#....#.......
31+
###...#.....#....#...#..#...#..
32+
...##..#.#.....#..#..#...#.#.##
33+
#.......#......##...##......#..
34+
.....#..#.....#......#.....##..
35+
..#.....###......#.#..###....#.
36+
....##........#...##.#..#..#...
37+
#...#.##...##..#####...##..##..
38+
...#.#.#.#.....#.#.........##..
39+
.............#......#..##...#..
40+
.#..#...##....#......#......#..
41+
#.....#...##......#............
42+
.#.#....##.#.#..##..#####..##..
43+
..#..#.....#..#.##..#.#......##
44+
.......#...#...#..#..##.#..##..
45+
...#.##....#....#..#..#..#.....
46+
.....#......#.....#.....#..#.#.
47+
..........#####.#..#....##...##
48+
....#...#...#....#.......#.....
49+
#.......#........#.##.####..###
50+
.#........#...##...#.....#....#
51+
...#.............#........#.#.#
52+
..##........#..##..##.##...#.#.
53+
......##......#####.........##.
54+
...##.....#.#.##....#####......
55+
.#.#........####.......#.#....#
56+
.....#..#.#.#.......##...#...#.
57+
.....####.#...#.#..#...#..#...#
58+
#..#.....#...#..#..#.#....#..#.
59+
.....#.......#..#.##..#.#.....#
60+
.......#..##..###......#.......
61+
.......##.#.##..##.#.###...##..
62+
..#.....#.....#....##.##.#..#.#
63+
###.#...#..##..#....#.#.#..#.#.
64+
#...#.#.........##........#....
65+
#...#.#..###.....###..##.......
66+
.....##..#.#...#.....#....#...#
67+
##...##..#.#.#..#.#.##..#....##
68+
.#.......#.#.........#.##..#...
69+
....##.#............###.#...##.
70+
#.....##.###.#..#....##.....#..
71+
....#.#......##.####....#....#.
72+
.....#......##.#...#....##.#...
73+
##...#.............#...#.......
74+
..#..#......#.#..#..#.....###..
75+
....#...#.#...#...#.....#..###.
76+
.....#.......#....#...#...#...#
77+
..####......#.#..###...........
78+
..........#....###.#.#.....###.
79+
#.............#...#..#.###.#..#
80+
.......#...#.#.#.#...##...#..#.
81+
...#.#..#..#...###.#.#.........
82+
#.###.#..#...#..#....#..#.#....
83+
...#.#.##..#...#.#......###.##.
84+
.##..#..##..#.....##.##....#.##
85+
..##.........####..............
86+
.#.#..###...#.........#...##.#.
87+
....##.........#.........##...#
88+
...#.#.......#..#...###.#.##.#.
89+
..#....###......#.##...........
90+
.......#...#.....#.#..#.#...#..
91+
.##..#...#..#...#..#...#.#..##.
92+
.##...#..##..##.#.#...##.......
93+
.#.##.#...#..#..#..........#.#.
94+
#.#.#...#......##...##..##.....
95+
.##..#............#.##....#.#..
96+
.##.........##..#.....#...#...#
97+
##.#.#.#.#...#.....##....##.#..
98+
#..##......#..##.........#.#...
99+
...#....#.#.#.##.....##........
100+
...#...#...#.##.#.#.#..#..#....
101+
.......#..#.......##...#....##.
102+
#.....#.#......#.......#.##.#.#
103+
.##..#.....#.....#.#####.#....#
104+
......#.#....#..............##.
105+
##..#...........#.#.#.......#..
106+
..##...###...#.#.........#....#
107+
..##..#.#....##.....#.#.......#
108+
....###...#.###....###.......#.
109+
..#.#.....#..#..#...........##.
110+
.###..#.#........#..#.....##.#.
111+
#.##........###.#..#.....#....#
112+
.#.#.....#.#.#..#...##.#...#...
113+
#.#.#...#.#........#..##..##...
114+
..#.##....###.#.......#.#.#....
115+
.....#...##...................#
116+
#..####.....###.#..........#...
117+
#.##.........###.#........#..#.
118+
..##........#.......#..###..#.#
119+
##..##..#.#..#..#.....#.#..#...
120+
....#......#....#...#.#.#..##.#
121+
.##....#.##.#.#..###..#......##
122+
###....###.##....##......###..#
123+
.##....#..###..##..#.###...##..
124+
.#.......##..##.............##.
125+
.###..#.....#.....#.#.#..#...##
126+
......##.###.#........#..#.....
127+
#####.....##.#.#...#...#.#.#...
128+
##..##.####...##....#...#.#...#
129+
.#.##...#...#..#...............
130+
##.##.#..#........#...#........
131+
..#.##.#....#...#.#.###..#....#
132+
.......#.#..#.....##.#.#...#.#.
133+
..#.##...#...#......#...#.#.#..
134+
.##.......##......#.....#......
135+
.#....................#.#...###
136+
..#.....#..##.#......##..#....#
137+
.....#.#...#...........#.#...##
138+
...#..#....#.#..#.......#..#..#
139+
.#..#.#...#.#.#.....###........
140+
.#.#.....#..#.##..#.#..##......
141+
..##..#..#.....###.##..#.....##
142+
.#..#.#...#.....#..#......##.#.
143+
.##.##.#.#.#.#.#...###..##...#.
144+
......#.##.#..#.##.#...#.#..#.#
145+
..#.....#.##....#......#..#....
146+
.#.....#..###.............#...#
147+
.#.....#...#...#.#.#.#..#.#....
148+
.#.....#......##.....#...#.#..#
149+
.#.#......##...#......#......#.
150+
##....#...#..##.#...#..#.......
151+
....#.#......#.##...#.........#
152+
#.#.##.#..#......#....#.......#
153+
.#..#.##..#..#........#.#...#..
154+
..#..#.#.#...#....#...#..#..###
155+
....#....#..#......#..........#
156+
#.....#.......#..#....#.#.#..#.
157+
....#.#..###.#.....#.####......
158+
##.#.#....##.#.#........#..#..#
159+
#.#...#...#.#...##..#.#..#.#...
160+
##.#......###.##.......#..#....
161+
#..#...#.......##....#.###.....
162+
.####.##....#..#..####.#....#.#
163+
#...#.#..#.....................
164+
..###..#...##.....##...........
165+
..#....#...###.#.........##.##.
166+
......#.....#....#.#....##...##
167+
#..#.....#...#..##.....#....#.#
168+
..#.#..#....##...###.#..##....#
169+
#....#..#..#..#.##.##.....#...#
170+
......#.#..#..##.#.....#.#..###
171+
.....##...##..#...##..#...#....
172+
##....#...#..#...##..#...###..#
173+
.##.####..#......#.#..#.##....#
174+
..###........###..#....##.#....
175+
...#.....##...##..##..##..#....
176+
.#..#.#..##..#..#..##.....#...#
177+
##.#..##...#..#...........##...
178+
....#..#..###.....#....#..#..##
179+
......##..#....##........#.#.##
180+
.#.##....##.#......#..##..#..##
181+
.....##.#..#.#.##.##.##..#...#.
182+
.#..##.#.....#####...#.........
183+
....#....#...#..##.#.#..##...#.
184+
...#..#...#............#..#....
185+
....#.#.#.##....##.###..#.#....
186+
.........#...###.........#..#.#
187+
...........#...##.#..#.#.#..#..
188+
#..#.###..#.#..#..##.....#....#
189+
.#.#....#.#....#...............
190+
...#.#..#.#..##.#.#.#.......#..
191+
.#......#...#.####......#..#...
192+
..##..#.#...#..#.......###.....
193+
.#.....#.#..##....##.####.##.#.
194+
.............##.#.#.....#..#.#.
195+
#.....##.#...#.#.#.######.##...
196+
.##...........#..#..##.####....
197+
#.#............#....#.........#
198+
..#.##.##.#..#....##....#..#.##
199+
#...#.##..##.##.#.....##.#....#
200+
##.#..##.###..#.#.#..........#.
201+
...##...#..#...#.#.#.###.###...
202+
#.....##......#...#.#...#......
203+
#.#.#.#.#.#...#..#....###...#..
204+
...##.#...#.......#..#...##.#..
205+
..#..#..##.....#......##...###.
206+
.............#.##...#.#.###..#.
207+
..#.#.....##..#.##..#...##..#..
208+
..#...#.##..###..........#..#..
209+
#.##.##...###...........#....#.
210+
#.....##...#.#..............#..
211+
##..##.....#...#..####.#...##..
212+
...........#......##.###..####.
213+
#...#..##.##.######.....#.....#
214+
#.##.........##.#.#....##...#..
215+
.##.#.......###.#.....#.....###
216+
###.#.#.#.#.#.##......#..#..#.#
217+
....#.###...#....#.##...##.##..
218+
....#..#.....#.#.#..#..##.#....
219+
....#..#..#.....#.#..##........
220+
..........#..##..##......##..#.
221+
#...##.......#...##.#...###..#.
222+
..#.#.##.....##....#..#.##...#.
223+
.#.#.....#.......##.....##...#.
224+
#......#.........#.#.........#.
225+
.......#...##......#.........#.
226+
..##..........#....#..#.......#
227+
.......#............#..#.#...#.
228+
#..#....#.#..#....##..#........
229+
....#..###.##..#.#..#.##..###..
230+
....###............##.#....#.#.
231+
..#..#.##...#....#..####...#...
232+
..#....#...#...##...#.#.#..#...
233+
..#.........#.#.......#........
234+
.........##.##.#..#.#...#.#..##
235+
#.....#.#....##.#####.......##.
236+
.#..#....#......#.##..#....#...
237+
........#....#...........#...#.
238+
.......#......#..........#..##.
239+
.###.#......#..#.##..#...#.#...
240+
.....#..#..###...........#...#.
241+
..#...##....###......#....#....
242+
...#.#..#.#.#......#.##.###.#.#
243+
.##....#...#..#.#..#........#..
244+
......##.###...##.#.#.........#
245+
.#...#..####..#.#..##........#.
246+
#..#...#..#..#.#...#..##...#..#
247+
..###...###....#.#.#.##....#..#
248+
.#.#....#.#.#......##....#..#.#
249+
##.#.#.####....#........#....#.
250+
...#......#........#...........
251+
#.#............##......#.##....
252+
..##.#...#.....#.#..#.#..#.#.#.
253+
#.......##.....##...#.#.#...###
254+
............#..#..#....#......#
255+
.#.##...###...#...###..#.......
256+
...............#....#...#.#.#..
257+
#..##..##.###...#..##...#.#.##.
258+
..#..#.......#.##......#..#..#.
259+
#.....#............#......#...#
260+
.###.##......##.#...#.#.##..#..
261+
.#..##..#..#..#.............#..
262+
#...#...##..##........#........
263+
...#........#..###...........#.
264+
#.#..#.#...................#.##
265+
#...#.#..#.......##...###..#.#.
266+
..####......#....#.#....#..#..#
267+
....#...........#...#..#.......
268+
...#..#....#.#.##...#.#.#.#....
269+
#...##.#.##..#.......#.....#...
270+
.##....#...#.#....#....#.#...#.
271+
##.#...#.#...##..#..##...##..#.
272+
#..#.#.........#.......#.......
273+
.....##.....#..#......##....#.#
274+
.###...##.#.#.#....#....#....#.
275+
#.#.#.............#.#..#.......
276+
#.......#..............#...#.##
277+
.#.#...#....#.........###...#.#
278+
..##..###..#...#...#.#....##..#
279+
.#..#.#...#..#.....#....#..##..
280+
##.......##....#....###..#.#..#
281+
#.#.#####..........#.#...##..##
282+
......#..#..#...#...##...#....#
283+
#..#......#...#...#..###.......
284+
...####.....#.......#.#...##.#.
285+
......#..#.....##..#...........
286+
#........#..#...#.....#...#.#..
287+
..#.....#..#......#.#.#.....#..
288+
..#.........#..##...#...#...#..
289+
##..##......#.........#........
290+
..#..#....#.##.#....###.#..#.##
291+
..##..#..#.......###....#..#...
292+
...#.#...#.....####.#..........
293+
........#..#..#.#.....#........
294+
...##..........#.#.#.....#..#..
295+
..#....#.......#...............
296+
.#..#.#.#.##..#..#.....#.......
297+
#.##.#.#..#..............#.....
298+
.#.#..#.....##..##....##.....#.
299+
.##.#..#........##.##...##.....
300+
#....##..#............#....#...
301+
...............##.#...#..#.....
302+
..#..##.##...#.#.....#.........
303+
.##..#.#.#.##.....#.#.#..#..##.
304+
......#####.#...#..........##..
305+
..........##.##...#.....#.#....
306+
..##......#..#.###..#...#.##...
307+
.#...........#.....#.#........#
308+
.#...#................#......#.
309+
#...#.#..##.#####..##....#.....
310+
...##...##..#.#..........#.....
311+
##............#......##..##...#
312+
###.#.......#..#...#..#..#...#.
313+
.#..##.....###.#.#............#
314+
##.###.#.........#.......#.#..#
315+
...#..##..#.....#.......#......
316+
......#.#..#.....##..#..##.....
317+
...#........##..###.#....#..#..
318+
..#...##.##....#.##..###......#
319+
..#...#.....#.####.....#...#.##
320+
..........##....###..#...#####.
321+
....#.#.#.#.#.##.............##
322+
.#.#.#.##......#......#....#.#.
323+
.##...##....#...#....#..###.#.#

src/day2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77
)
88

9-
// SolveDay2 solves the puzzle for day1
9+
// SolveDay2 solves the puzzle for day 2
1010
func SolveDay2(part int, lines *[]string) {
1111
switch p := part; p {
1212
case 1:

src/day3.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// SolveDay3 solves the puzzle for day 3
8+
func SolveDay3(part int, lines *[]string) {
9+
switch p := part; p {
10+
case 1:
11+
solveDay3Part1(lines)
12+
case 2:
13+
solveDay3Part2(lines)
14+
}
15+
}
16+
17+
func solveDay3Part1(lines *[]string) {
18+
solution := 0
19+
20+
solution = solveDay3SlopeRun(lines, 1, 3)
21+
22+
fmt.Println(solution)
23+
}
24+
25+
func solveDay3Part2(lines *[]string) {
26+
solution := 0
27+
28+
down1right1 := solveDay3SlopeRun(lines, 1, 1)
29+
down1right3 := solveDay3SlopeRun(lines, 1, 3)
30+
down1right5 := solveDay3SlopeRun(lines, 1, 5)
31+
down1right7 := solveDay3SlopeRun(lines, 1, 7)
32+
down2right1 := solveDay3SlopeRun(lines, 2, 1)
33+
solution = down1right1 * down1right3 * down1right5 * down1right7 * down2right1
34+
35+
fmt.Println(solution)
36+
}
37+
38+
func solveDay3SlopeRun(lines *[]string, down int, right int) int {
39+
solution := 0
40+
41+
for i := 0; i < len(*lines); i += down {
42+
line := (*lines)[i]
43+
44+
treePos := (i / down * right) % len(line)
45+
character := string(line[treePos])
46+
47+
if character == "#" {
48+
solution++
49+
}
50+
}
51+
52+
return solution
53+
}

0 commit comments

Comments
 (0)