Discussion thread for day 6 of the Advent of Code - https://adventofcode.com/2023/day/6
So glad today was easy!
Had to tap into my 8th grade math for this one... It's been a while since I've dealt with parabolas...
Total_distance = hold_ms * (total_ms - hold_ms)
9 < hold_ms * (7-hold_ms)
9 < 7 * hold_ms - hold_ms^2
0 < 7 * hold_ms - hold_ms^2 - 9
0< -hold_ms^2 +7hold_ms - 9
x = (7 +- Sqrt( 7**2 - 4*-1*-9)) / 2*-1
x = (7 +- sqrt( 49 - 36)) / -2
x = (7 +- 3.6) / -2
x = (-10.6 or -3.4)/ -2
3.4/2 < x < 10.6/2
1.7 < x < 5.3
I'm going to take the ceiling (round up) for dist_a and Floor for dist_b after adding a slight edge (+.00001 to dist_a and -.00001 to dist_b) to BEAT the record (since the quadratic formula solves to equals)
Then, I'll subtract the two numbers and add 1 (to include the first number which isn't counted when subtracting).
Day 5 pt 2 still to come after last night's fiasco. Good to have a nice one again :)
#TeamBruteForce
@cgoodman3 obvs different hardware, but my brute force runs in 28 seconds
After Day 5 mistreated me badly (mostly due to my own incompetence), today was like a big cosy hug made of clouds.
M.
@cgoodman3 I had the same thought process when tackling this. Took 30 seconds to run
Kickin' it 8th grade-style with a little quadratic formula (after the long way in part 1)!
Solved! For Part 2, I initially used my Part 1 brute force solution. I then redid it using the quadratic formula (complete with singing the song to myself for the formula 🤓)