Int 3 for Programmers
What to charge before fees
A marketplace takes a percentage of whatever you charge, and then a flat fee on top. If you list an item at pence, what you keep is given by a function of .
Sellers need that function run backwards. Write gross_needed(target, fee_percent, flat), which returns the smallest whole number of pence to list the item at so that the amount kept is at least target.
Worked example, with target = 1000, fee_percent = 10 and flat = 50. Keeping at least 1000 means , so and . Prices are whole pence, so round up: the answer is 1167. Checking, listing at 1167 keeps pence, which clears the target, while 1166 keeps 999.4, which does not.
target and flat are between 0 and 100000, and fee_percent is between 0 and 99.Run your code to see how it does on the examples. Submit also runs the hidden cases.