Int 3 for Programmers
When the other plan wins
Two hire companies quote in the same shape: a fixed charge plus a charge per day. Company one costs base1 + rate1 * days and company two costs base2 + rate2 * days, everything in pounds.
Write cheaper_after(base1, rate1, base2, rate2), which returns the smallest whole number of days at which company two costs strictly less than company one. If that never happens for any number of days from 0 to 10000, return -1.
Worked example, with base1 = 30, rate1 = 2, base2 = 0 and rate2 = 6. At 0 days company two costs 0 against 30, so it is already cheaper and the answer is 0.
Second worked example, with base1 = 10, rate1 = 9, base2 = 50 and rate2 = 4. At 8 days the costs are 82 and 82, which is a tie rather than a win. At 9 days they are 91 and 86, so the answer is 9.
Run your code to see how it does on the examples. Submit also runs the hidden cases.