wip d2p2
This commit is contained in:
@@ -4,7 +4,7 @@ import {readFile} from "../../utils";
|
||||
|
||||
let input = readFile(path.resolve(__dirname, 'input.txt'));
|
||||
|
||||
const ans = Math.max(
|
||||
const day1 = Math.max(
|
||||
...input
|
||||
.split("\n\n")
|
||||
.map(a => a.split("\n"))
|
||||
@@ -13,5 +13,16 @@ const ans = Math.max(
|
||||
.reduce((a, b) => a + b), 0)
|
||||
)
|
||||
|
||||
console.log(ans);
|
||||
console.log("Day1:", day1);
|
||||
|
||||
const day2 =
|
||||
input
|
||||
.split("\n\n")
|
||||
.map(a => a.split("\n"))
|
||||
.map(buck => buck.map(Number).reduce((a, b) => a + b), 0)
|
||||
.sort((n1,n2) => n2 - n1)
|
||||
.splice(0,3)
|
||||
.reduce((n1, n2) => n1 + n2)
|
||||
|
||||
|
||||
console.log("Day2:", day2);
|
||||
Reference in New Issue
Block a user