Day 6 problem 1 asks us to consider a series of toy boat races. The longer you have the boat on the charger, the faster it’ll travel during the remaining units of time. With how many different integer charge times can you beat the record distance in that race?
The distance traveled is (ignoring units) tcharge ( ttotal – tcharge); so the answer to the problem can be found directly by using your favorite quadratic solver on tcharge2 – ttotal tcharge + drecord = 0, which will have zero, one, or two real solutions. If it has zero solutions, one solution that’s non-integer, or two non-integer solutions between two consecutive integers, then there are zero integer charge times that beat the record. Otherwise count the number of integers from the floor of the lower solution plus one to the ceiling of the upper minus one. (That sounds weird but math it out — it ensures not merely tying the record but beating it.)
Anyone who remembers algebra and has dignity and self-respect would use this trivial approach.
I wrote a program to count winning charge times by iteration.