Drill

ProblemsPython › finance

How much survives a round trip

mediumfinancePython

Money changes from currency A to B to C, and the rates are given in basis points per leg. Find what is left in the end.

exchange_round_trip(amount_minor: int, rate_a_bbps: int, rate_b_cbps: int) → int

Solve it in the editor →

Where you start

def exchange_round_trip(amount_minor: int, rate_a_bbps: int, rate_b_cbps: int) -> int:
    

Worked examples

CallResult
exchange_round_trip(200, 1000, 2500)5
exchange_round_trip(100, 5000, 2000)10
exchange_round_trip(1000, 1000, 1000)10
exchange_round_trip(100, 8000, 1000)8

Hint

Multiply all three factors, then divide once by a hundred million.

Reference solution in Python
def exchange_round_trip(amount_minor: int, rate_a_bbps: int, rate_b_cbps: int) -> int:
    return amount_minor * rate_a_bbps * rate_b_cbps // (10000 * 10000)

The same problem in another language

More finance problems in Python