Day 6 part 2

This commit is contained in:
Simon Cambier 2023-12-07 08:41:15 +01:00
parent ee6e32dd3d
commit 2dd97d116f

View File

@ -4,6 +4,9 @@ type Race = {
};
const races: Race[] = [];
// const input = `Time: 47 70 75 66
// Distance: 282 1079 1147 1062`.split("\n");
const input = `Time: 47707566
Distance: 282107911471062`.split("\n");
@ -22,7 +25,6 @@ function getSpeed(race: Race, holdTime: number): number {
return (race.time - holdTime) * holdTime;
}
let mul = 1;
const counts: number[] = [];
for (const race of races) {
@ -43,6 +45,8 @@ for (const race of races) {
counts.push(to - from + 1);
}
let mul = 1;
for (const count of counts) {
mul *= count;
}