<- back

advent of code - day 6

2023-12-06

See the puzzle here.

See my full solution here.

This whole day was shockingly easy. The whole time I was suspicious I was overlooking some trap, trick, or edge case, but nope.

For both parts, it basically boiled down to this:

let wins = 0;
const raceTime = times[i];
const totalDistance = distances[i];
for(let j=1; j  const holdTime = j;
 const speed = holdTime;
 const timeToTravel = totalDistance / speed;
 if((timeToTravel + holdTime) < raceTime) {
  wins++;
 }
}