From 2dd97d116fc2c6f008ffb652bfb41a629b2dd47f Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Thu, 7 Dec 2023 08:41:15 +0100 Subject: [PATCH] Day 6 part 2 --- day6/day6-ts.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/day6/day6-ts.ts b/day6/day6-ts.ts index a5bca51..f768cf9 100644 --- a/day6/day6-ts.ts +++ b/day6/day6-ts.ts @@ -4,8 +4,11 @@ type Race = { }; const races: Race[] = []; -const input = `Time: 47 70 75 66 -Distance: 282 1079 1147 1062`.split("\n"); +// const input = `Time: 47 70 75 66 +// Distance: 282 1079 1147 1062`.split("\n"); + +const input = `Time: 47707566 +Distance: 282107911471062`.split("\n"); // parse input const [t, ...rtimes] = input[0].split(" "); @@ -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; }