xAI

Verified interview challenge

Build a fixed-window token limiter

Track per-key token usage correctly as requests cross time windows or trigger a reset.

Unlock with Full Access

The challenge

Build a fixed-window limiter in which every key has its own token usage. A request consumes quota in its current window, and the count starts afresh when time enters the next one.

Extend the implementation with per-key resets and the full workload. The important cases occur where an operation changes eligibility, including a window boundary or a reset that must not affect another key.

What you'll practise

  • Window state

    Associate usage with the right key and active time window.

  • Boundary correctness

    Keep admission and reset operations consistent at quota and timestamp edges.

Your coding workspacePreview
Current partFurther parts unlock as you progress
solution.pyPython 3.13
# Build on your implementation

# Run checks for the current part

# Full starter code included
Current-part checks

Run your code to see results.

The complete sequence, starter code and checks are included with Full Access.