SoloMedium25m

The Usage Total That Ignored a Correction

### P2 · Usage-report smoke check fails The authored fixture totals 19 over buckets [0, 3). Bucket 1 is corrected from 9 to 2. Expected total: 12. Observed total: 19.

Your task: Repair UsageIndex in usage_index.py so point assignments and half-open range sums stay consistent with logarithmic indexed work. Preserve exact integer arithmetic, input validation and independent instances.

Run python monitor.py and python -m unittest -v, then open a PR against main. This is an offline single-process teaching fixture, not live usage or billing telemetry.

Skills you'll prove

pythondata-structuresrange-queriestestingdebugging

Interview Tip

I replaced a static prefix snapshot with a mutable indexed sum structure. An assignment propagates the difference from the old bucket value; a range total subtracts two prefix aggregates. Each operation touches logarithmically many cells rather than rebuilding a suffix.

Browse freely — sign in when you're ready to open a ticket and prove your skills.