From 21272f7281b2111a1817b96d565f8a865a73a427 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 2 Dec 2021 20:03:47 +0100 Subject: [PATCH] Solve day 1 part 2 --- 2021/day01.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2021/day01.js b/2021/day01.js index c329c1f..09d7737 100644 --- a/2021/day01.js +++ b/2021/day01.js @@ -1,4 +1,4 @@ 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);