Command Palette

Search for a command to run...

Hectal
Phase 11: Observability and Operations
LLM Engineering · Exercise 4 of 5 PreviousNext
Advanced

An alert rule with a minimum volume

windows is a list of (requests, errors) per window. Write error_alert(windows, limit_percent, min_requests, in_a_row) that returns the 0-based index of the window where the alert fires, or -1.

A window is bad when it has at least min_requests requests and errors * 100 // requests is greater than limit_percent. The alert fires in the window where the count of consecutive bad windows reaches in_a_row. A window that is not bad resets the count.

What Check tests

  1. Fires in the second bad window
  2. One bad window is not enough when two are needed
  3. Too few requests never count
  4. A window with 0 requests does not crash
  5. The limit is exclusive

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.