Code review test

Find the Bug

AI writes more of the code now. Someone still has to read it. Each question is code that runs, looks clean and gives a plausible answer. One line is wrong. Read it, then pick the line and the reason.

Settings

Language

Level

This run

Python, Easy: 8 bugs in 12 minutes. Plain logic: off-by-one, a wrong comparison, the wrong variable.

Sign in to play, so the server can mark your run.

Your results

Warm up

average_fill.py
def average_fill(fills):
"""Volume-weighted average price of a list of (price, qty) fills."""
notional = sum(px * qty for px, qty in fills)
total_qty = sum(qty for _, qty in fills)
return notional / len(fills)
Read onlyLn 1, Col 1Spaces: 4UTF-8Python
Warm up: which line is wrong?

Line 5. It divides by the number of fills, not the total quantity, so a small fill counts as much as a big one.

How it works

Each question is a short program in Python or C++ that runs and gives a believable answer, with exactly one wrong line. The slip is in the logic, never a typo or a style point. Four options each name a line and say what is wrong there. Pick one by clicking the option or the line. You get 8 bugs in 12 minutes, and the run is sent when the clock reaches zero. You score 1 for each bug you find, and the review shows every bug, why it matters and the fix.

  • Read the brief first

    The brief says what the code should do. Check each line against that, not against whether it looks tidy.

  • Run a tiny case

    Push a small input, such as two fills or three prices, through the code in your head. A wrong total usually points at the line.

  • Check the edges

    Loop bounds, the first and last element, division by a count and units are where most bugs sit.

Questions about Find the Bug

  • Code review: reading code you did not write and finding the line that gives a wrong answer.

  • Python or C++. Pick one before you start. Each run uses one language.

  • Easy is plain logic: off-by-one errors, a wrong comparison, the wrong variable. Medium is desk numbers: fees, compounding, annualising, units and prices. Hard is a wrong method: lookahead, leakage, stale state and aliasing.

  • No. You cannot type in the editor or run anything. Read it the way you would review a pull request.

  • The run cannot come back after a reload and its answers are not marked. Start a new run when you are ready.