d6p1 calculte records

This commit is contained in:
Baipyrus 2023-12-08 11:35:23 +01:00
parent ccb408c9e2
commit 49bc03e1ef

View File

@ -10,7 +10,15 @@ const distance = input[1]
.split(/\s{1,}/) .split(/\s{1,}/)
.slice(1) .slice(1)
.map(Number); .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(); const t1 = performance.now();
console.log(`Runtime: ${t1 - t0}ms`); console.log(`Runtime: ${t1 - t0}ms`);