advent-of-code/2021/day01.js

4 lines
237 B
JavaScript
Raw Normal View History

2021-12-02 19:59:48 +01:00
let total = 0;
2021-12-02 20:03:47 +01:00
$("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});
2021-12-02 19:59:48 +01:00
console.log(total);