Cookie Clicker Alpha, Qualification Round 2014.
This problem is also fairly simple, and we can solve it with a straightforward algorithm. Many thanks to both Dashamir and Karell who pointed out ways to simplify my original solution in the comments.
We want to decide for each farm if we’ll be able to win faster without buying the next farm (which will take time) or with buying the next farm (which will take time to save up cookies to buy the farm and a further time to win with the new, higher, production rate. If we don’t buy the farm, we report the current time plus the time to win with the current rate. If we do buy the farm, then we just repeat the step above after incrementing our rate and time to account for the new farm purchase.
def solve_case(case): C, F, X = case rate = 2.0 time = 0.0 while True: time_if_wait = X / rate time_if_buy = C / rate + X / (rate + F) if time_if_wait <= time_if_buy: return time + time_if_wait time += C / rate rate += F