• + 0 comments

    What worked for me was to avoid floating math entirely: normalize rates and amounts to integers (basis points, cents), and compute costs with prefix sums over time “events.” Greedy fails when later cheaper windows exist, so I modeled feasibility and used a binary search on the final cost/limit, validating with a linear check per mid. Mid-way through debugging I realized that, like finances in real life, clarity beats guesswork; a concise guide on checking one’s credit history helped me think more systematically: https://lovilave.com.ua/blog/yak-pereviryty-svoyu-kredytnu-istoriyu. Back to code—pre-sort events, consolidate identical timestamps, and add tests for zero/very high interest, exact boundary fits, and cumulative overflow. This stabilized both performance and accuracy.