Drill

ProblemsPython › monitoring

What share of requests failed

easymonitoringPython

A status page shows the error rate as a whole percentage, because nobody reads four decimal places at a glance.

error_rate(errors: int, total: int) → int

Solve it in the editor →

Where you start

def error_rate(errors: int, total: int) -> int:
    

Worked examples

CallResult
error_rate(5, 100)5
error_rate(1, 3)33
error_rate(2, 3)67
error_rate(0, 100)0

Hint

Add half the divisor before dividing, then cap.

Reference solution in Python
def error_rate(errors: int, total: int) -> int:
    if total <= 0 or errors <= 0:
        return 0
    return min(100, (errors * 100 + total // 2) // total)

The same problem in another language

More monitoring problems in Python