Signals
Services ranked by failures
Prioritize an incident by counting server errors per service. Rank the services with errors.
In production
On-call sorts services by error volume. A wrong rank sends people into the quiet service first.
What it must return
Count only records that count as errors, then rank services by descending count and ascending name on ties.
- Records have service (string) and status (integer). Count statuses 500–599 only. Return service names by count descending, then name ascending for ties.
- Do not mutate input values. Use the Python standard library only.
Edge cases
- Filter before you count.
- Tie-break is lexicographic service name.
- Services with zero errors do not appear.
Signature
rank_errors(records)Hints
Second hint
A partial sketch
The reference solution opens after the last hint.
Loading editor…
Prioritize volume
records
[
{
"service": "api",
"status": 500
},
{
"service": "jobs",
"status": 503
},
{
"service": "api",
"status": 502
}
]Expected
[ "api", "jobs" ]
Each run uses a fresh Python runtime in this browser, with a 3-second limit and a Stop button. The first run downloads the runtime. 0 of 12 in Signals passed in Python on this device.