mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-12-28 13:01:45 +00:00
mutable instead of array of size 1
This commit is contained in:
parent
5cf420dc26
commit
2d980c7717
@ -20,13 +20,13 @@ const predictions = histories.map((e) => {
|
|||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
const last = sequences.pop();
|
const last = sequences.pop();
|
||||||
const extrapolated = [[...last, last[0]]];
|
let extrapolated = [...last, last[0]];
|
||||||
for (const s of sequences.reverse()) {
|
for (const s of sequences.reverse()) {
|
||||||
const current = s.pop();
|
const current = s.pop();
|
||||||
const last = extrapolated.pop().pop();
|
const last = extrapolated.pop();
|
||||||
extrapolated.push([...s, current + last]);
|
extrapolated = [...s, current + last];
|
||||||
}
|
}
|
||||||
return extrapolated.pop().pop();
|
return extrapolated.pop();
|
||||||
});
|
});
|
||||||
const sum = predictions.reduce((a, i) => a + i);
|
const sum = predictions.reduce((a, i) => a + i);
|
||||||
console.log(sum);
|
console.log(sum);
|
||||||
|
Loading…
Reference in New Issue
Block a user