From 49bc03e1ef84a0f8314898cf2bd19d705326634f Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Fri, 8 Dec 2023 11:35:23 +0100 Subject: [PATCH] d6p1 calculte records --- Day6/Part1.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Day6/Part1.js b/Day6/Part1.js index 6cb6a0d..3ae0918 100644 --- a/Day6/Part1.js +++ b/Day6/Part1.js @@ -10,7 +10,15 @@ const distance = input[1] .split(/\s{1,}/) .slice(1) .map(Number); -console.log(time, distance); +const records = time + .map( + (a, i) => + [...Array(a - 1).keys()] + .map((b) => (a - (b + 1)) * (b + 1)) + .filter((b) => b > distance[i]).length + ) + .reduce((a, i) => a * i); +console.log(records); const t1 = performance.now(); console.log(`Runtime: ${t1 - t0}ms`);