Tiered Sales Commission

Medium ⏱ 12 min 58% acceptance ★★★★★ 4.7
Commission is marginal, like income tax: 2% on the first 50,000 of sales, 5% on the next 50,000, 8% beyond 100,000. Write commission(sales) computing it correctly — the classic mistake is applying the top rate to the whole amount.

Examples

Example 1
Input
commission(120000)
Output
5100.0
Explanation

1000 + 2500 + 1600: each band pays its own rate.

Example 2
Input
commission(30000)
Output
600.0
Explanation

Entirely inside the first band.

Constraints

  • Marginal bands, not flat.
  • Return a float.

Topics

Business Logictiered rates

Companies

SalesforceHubSpotZoho

Hints

Hint 1

Process band by band, subtracting as you go.

Hint 2

min(remaining, band_width) is the amount in each band.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.