Command Palette

Search for a command to run...

Hectal
Phase 11: Observability and Operations
LLM Engineering · Exercise 2 of 5 PreviousNext
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

  1. p50 of 1..10 is 5
  2. p95 of 1..20 is 19
  3. The input list is not changed and need not be sorted
  4. A single value is every percentile
  5. 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.