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
- Fires in the second bad window
- One bad window is not enough when two are needed
- Too few requests never count
- A window with 0 requests does not crash
- 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.