Intermediate
Nearest-rank percentiles and a latency report
Write percentile(values, p) using the nearest-rank rule: sort the values and return the one at position ceil(p * n / 100) counting from 1. Use integer arithmetic only: (p * n + 99) // 100.
Write latency_report(latencies) that returns "p50=<a> p95=<b> max=<c>", or "no data" for an empty list.
What Check tests
- p50 of 1..10 is 5
- p95 of 1..20 is 19
- The input list is not changed and need not be sorted
- A single value is every percentile
- The report line and the empty case
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.