10 XP challenge
Track a Bounded Reservoir
easy
Build it yourself · 6 min
1 Learn2 Predict3 Solve
TaskYour mission
Start with initial water, apply each signed change in order, and clamp the water to 0..capacity after every change. Return final water. 0 <= initial <= capacity <= 100. All lists have at most 20 items; text is ASCII and at most 30 characters. Numeric inputs and list items are between -100 and 100 unless a narrower range is stated.
Examples
| Input | Return |
|---|---|
numbers = [], initial = 3, capacity = 5 | 3 |
numbers = [5,-2], initial = 0, capacity = 4answer: 0 → 5 → 4 → 2. The result is 2. | 2 |
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.