5 XP challenge
Withdraw Until Empty
very easy
Build it yourself · 3 min
1 Learn2 Predict3 Solve
TaskYour mission
Starting from balance, subtract amount once per period, clamping the balance to zero after each subtraction. Return the final balance. balance is 0 to 100; amount is 0 to 20; periods is 0 to 20.
Examples
| Input | Return |
|---|---|
balance = 10, amount = 3, periods = 2answer: 10 → 7 → 4. The result is 4. | 4 |
balance = 10, amount = 3, periods = 4answer: 10 → 7 → 4 → 1 → -2 → 0. The result is 0. | 0 |
Your code
Write your answer inside Solution, then use return to send it back.
Ln 1, Col 1
JavaScript
Try examples runs the public examples. Check my code checks your full answer and saves your completion.