Drill

ProblemsC# › finance

How much survives a round trip

mediumfinanceMathC#

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.

ExchangeRoundTrip(amountMinor: int, rateABbps: int, rateBCbps: int) → int

C# needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.

Solve it in Python →

Where you start

public int ExchangeRoundTrip(int amountMinor, int rateABbps, int rateBCbps) {
    
}

Worked examples

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

Hint

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

Reference solution in C#
public int ExchangeRoundTrip(int amountMinor, int rateABbps, int rateBCbps) {
    return (amountMinor * rateABbps * rateBCbps) / (10000 * 10000);
}

The same problem in another language

More finance problems in C#