Unit test algorithm bug in Python Numbers

For the Numbers exercise in the Python track, my initial algorithm for calculating task 6 failed. I adjusted it to make it pass, but no matter how I stare at it, it doesn’t seem correct.

For task 6, Calculate Value after Exchange we have budget (the amount we want to convert), an exchange rate, the spread (“The percentage that is taken as an exchange fee.”), then the denomination.

Seems pretty straightforward:

  1. Calculate the foreign_currency you will receive → budget / exchange rate
  2. Subtract the exchange fee → foreign_currency * (100 - spread) / 100
  3. Round down for denomination

However, when I do this it fails. What passes is substituting → foreign_currency * (100 / 100 + spread) for step 2.

But if the spread is 25, then they’re taking 25% of the converted currency before handing it to you. You get 75%. But 100/125 is 80%, not 75%.

It would be helpful to share actual code. The English version of the steps can be a bit ambiguous.

A 10% spread means you need to increase the exchange rate by 10%.