Skip to main content

Trace investigation

About 30 minutes. Pick a version and a test, predict the returned value, then step through the trace one line at a time. Your goal is to find a test that exposes each of the three buggy versions. This is a step-by-step simulation of these four procedures, not a code runner.

1. Choose a version

Version A is correct. B, C and D each have one planted bug. Read the code to find it.

2. Choose a test

Version A with [4, 0, 12, 7], threshold 5

Version A · CountAtLeast
PROCEDURE CountAtLeast(readings, threshold){  count ← 0  FOR EACH r IN readings  {    IF (r ≥ threshold)    {      count ← count + 1    }  }  RETURN count}

The step-by-step trace unlocks after you predict. Nothing is recorded.

Bug hunt: find a test that exposes each buggy version

  • Version B:not exposed yet
  • Version C:not exposed yet
  • Version D:not exposed yet

A test counts once you have predicted and run it. Progress lives on this page only and resets when you leave.