Log inBook a Demo
OptimizeMidBackendAuto-graded

Speed up a slow /report endpoint

The report gets much slower as the event log grows; make it scale linearly and keep every number exactly the same.build_report(store) in report.py rolls up page views per session from an event log. The numbers are right, but double the log and the work far more than doubles. The store counts every operation (store.ops, printed by python3 report.py), so you can measure it directly. Make the work grow linearly with the number of events and keep the report exactly as it is, session order included.
30 min
python

You're done when

  • On the 600-event log, build_report returns the identical report and stays within the operation budget.
  • The report stays identical at every log size, and the operation count grows linearly with the size of the log.

What it measures

Measuring firstFinding where the operations come from before changing any code.
Algorithmic fixA rewrite that changes how the work grows with the size of the log.
No regressionsKeeping the report identical, checked at more than one log size.

Your environment

Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards

Start this lab

30 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo