Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dfbfec2

Browse filesBrowse files
feat[2020-day-03]: calculate tree collisions for multiple slopes
Solution for part 2
1 parent de18ecd commit dfbfec2
Copy full SHA for dfbfec2

File tree

1 file changed

+14
-2
lines changed
Filter options

1 file changed

+14
-2
lines changed

‎2020/day-03/solution.js

Copy file name to clipboardExpand all lines: 2020/day-03/solution.js
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,20 @@ fs.readFile(filePath, { encoding: 'utf8' }, (err, initData) => {
2121

2222
const part2 = () => {
2323
const data = resetInput()
24-
console.debug(data)
25-
return 'No answer yet'
24+
const slopes = [
25+
[1, 1],
26+
[3, 1], // Same as default
27+
[5, 1],
28+
[7, 1],
29+
[1, 2]
30+
]
31+
// Multiple the results of multiple slopes
32+
return slopes.reduce((itr, slope) => {
33+
return itr * countTreesOnRoute({
34+
map: { rows: data },
35+
slope
36+
})
37+
}, 1)
2638
}
2739
const answers = []
2840
answers.push(part1())

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.