Day 6: Wait For It

AdventuRust - AoC 2023

This is Day 6 of Advent of Code 2023! If you would like to solve the problems before looking at the solution, you can find them here.

In part 1 of Day 6, the problem is an easy one. Looking at the puzzle input, I did feel a little confused because unlike the previous puzzles which had each row as a separate input, this one had each column as its own input and the rows were different variables. The idea is here that you have a time and a distance for a boat that has a particular mechanism of propulsion. Powering up the boat for n seconds at the beginning of the race allows your boat to go a speed of n units per second. The inputs to us are the allotted time and the record distance in that race. We need to figure out the number of ways in which we can beat the record. The logic behind the answer is pretty simple - d(n) = 0 * n + n * (time - n) - where d(n) is the distance achieved by powering for n of the time seconds. We count the values of n for which the distance is greater than the record and that is our answer. Click here to jump to the part 2 discussion.

For part 2 of Day 6, I was expecting a much more involved problem but all it was looking for is to see if the solution for part 1 could scale up efficiently. Instead of having multiple races, it combined all the values in the row to be one value. The parsing is a tad bit different as a result, but the main logic remains the same.

That's all folks! If you made it this far, enjoy some AI art generated by u/dimpopo using the prompt for this puzzle.

Cheers,
Devang