Electricity Units from Bill
EasyP3Coding
An electricity bill has a fixed charge of 80, then the energy charge is priced in slabs:
- the first 50 units cost 3 each
- the next 100 units (units 51 to 150) cost 5 each
- every unit after 150 costs 10 each
Given the total bill (fixed charge included), return the number of units consumed. The bill always matches a whole number of units. A bill of exactly 80 means 0 units. (The original exercise gave only the formula; this version states the slabs it implies.)
Example 1
- Input
- bill = 83
- Output
- 1
- Why
- The energy charge is 3, which buys 1 unit at 3.
Example 2
- Input
- bill = 80
- Output
- 0
- Why
- No energy charge.
Example 3
- Input
- bill = 230
- Output
- 50
- Why
- Energy charge 150 = 50 units at 3.
Constraints
- bill >= 80
bill - 80is the exact cost of a whole number of units.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.