mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-12-26 12:01:45 +00:00
d6p1 calculte records
This commit is contained in:
parent
ccb408c9e2
commit
49bc03e1ef
@ -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`);
|
||||
|
Loading…
Reference in New Issue
Block a user