bands, where bands[i] = [upper, percent]: income up to and including upper (above the previous limit) is taxed at percent percent. Bands are sorted by upper in increasing order.
So the first bands[0][0] coins are taxed at the first band's rate, the next bands[1][0] - bands[0][0] coins at the second band's rate, and so on.
Return the total tax owed on income. Answers within 10⁻⁵ of the exact value are accepted.bands=[[4, 10], [10, 30], [20, 50]], income=15 → 4.7
The first 4 coins are taxed at 10% (0.4), the next 6 at 30% (1.8), the remaining 5 at 50% (2.5). Total 4.7.
bands=[[2, 0], [6, 20]], income=3 → 0.2
Two coins fall into the tax-free first band, and one coin in the second band costs 0.2.
bands=[[5, 40]], income=0 → 0.0
upper values are strictly increasingupper is at least incomebands=[[4, 10], [10, 30], [20, 50]], income=15
4.7
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.