Day 6 part 2
This commit is contained in:
parent
ee6e32dd3d
commit
2dd97d116f
|
@ -4,8 +4,11 @@ type Race = {
|
||||||
};
|
};
|
||||||
const races: Race[] = [];
|
const races: Race[] = [];
|
||||||
|
|
||||||
const input = `Time: 47 70 75 66
|
// const input = `Time: 47 70 75 66
|
||||||
Distance: 282 1079 1147 1062`.split("\n");
|
// Distance: 282 1079 1147 1062`.split("\n");
|
||||||
|
|
||||||
|
const input = `Time: 47707566
|
||||||
|
Distance: 282107911471062`.split("\n");
|
||||||
|
|
||||||
// parse input
|
// parse input
|
||||||
const [t, ...rtimes] = input[0].split(" ");
|
const [t, ...rtimes] = input[0].split(" ");
|
||||||
|
@ -22,7 +25,6 @@ function getSpeed(race: Race, holdTime: number): number {
|
||||||
return (race.time - holdTime) * holdTime;
|
return (race.time - holdTime) * holdTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mul = 1;
|
|
||||||
const counts: number[] = [];
|
const counts: number[] = [];
|
||||||
|
|
||||||
for (const race of races) {
|
for (const race of races) {
|
||||||
|
@ -43,6 +45,8 @@ for (const race of races) {
|
||||||
counts.push(to - from + 1);
|
counts.push(to - from + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mul = 1;
|
||||||
for (const count of counts) {
|
for (const count of counts) {
|
||||||
mul *= count;
|
mul *= count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user