SLO error budget
A free easy coding practice problem from devops. Solve it in JavaScript, TypeScript or Python and check your solution against fresh hidden tests — edge cases and random inputs — as often as you like.
- Difficulty
- Easy
- Type
- Function
- Topic
- Devops
- Languages
- JavaScript, TypeScript or Python
Problem
An SLO is given in basis points: sloBp = 9990 means 99.90 % availability (9000 ≤ sloBp ≤ 9999). Over a window of windowMinutes minutes, the error budget is budget = floor(windowMinutes × (10000 − sloBp) / 10000) minutes. badMinutes minutes of downtime have been used.
Return [budget, remaining, status] where remaining = budget − badMinutes (may be negative) and status is "exhausted" if remaining ≤ 0, else "warning" if 4 × remaining < budget, else "ok". All inputs are non-negative integers, windowMinutes ≤ 10^7.
Function signature
// JavaScript
function errorBudget(sloBp, windowMinutes, badMinutes)
// TypeScript
function errorBudget(sloBp: any, windowMinutes: any, badMinutes: any): any
// Python
def error_budget(sloBp, windowMinutes, badMinutes):Examples
errorBudget(9990, 43200, 10)→[43,33,"ok"]errorBudget(9950, 43200, 200)→[216,16,"warning"]errorBudget(9999, 1000, 0)→[0,0,"exhausted"]
How checking works
Run your code against the examples above, then submit a check: it runs on the server against hidden tests built fresh each time, including edge cases and random inputs. Practice is untimed and never affects a verified score; when you are ready, take a graded coding challenge to earn a badge.