Solve day 1 part 2

This commit is contained in:
Gabriel Augendre 2021-12-02 20:03:47 +01:00
parent 8307409c2c
commit 21272f7281

View file

@ -1,4 +1,4 @@
let total = 0; let total = 0;
$("pre").innerText.trim().split("\n").map(el => Number(el)).reduce((prev, current) => {if (prev < current) {total += 1} return current}); $("pre").innerText.trim().split("\n").map(el => Number(el)).map((el, index, array) => el + array[index+1] + array[index+2]).reduce((prev, current) => {if (prev < current) {total += 1} return current});
console.log(total); console.log(total);