F03 · Topic 1.4
Bug clinic
1. Predict first
For values[5,5,1], minimum 5, predict an inclusive counter, a strict-greater counter and a counter reset inside each iteration.
Change it · step through · explain
Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.
Ready · Make a prediction
- Input 15,5,1Waiting
- Input 25Waiting
- Input 3boundaryWaiting
Ready to experiment
Why: Predict the first change, then advance one step.
Try this: Try repeated boundary values, no matches and an empty list.
2. Build your procedure
Write countAtLeast(values,minimum) with initialization outside the loop and return after the loop. Show one test exposing each of the two faulty versions.
Use AP CSP pseudocode, a language you know, or precise plain language. Your code is not executed here. Use the classroom assignment to save your response.
3. Check boundaries
| Input | Expected | Why this case |
|---|---|---|
| [5]; minimum 5; boundary fault | Correct 1, faulty 0 | Equality exposes the strict comparison. |
| [6,6]; minimum 5; reset fault | Correct 2, faulty 1 | Two matches expose lost accumulation. |
| []; minimum5 | Correct0 | Initialize and return even when the loop has no iterations. |
4. Explain and reflect
Why is changing two suspicious lines at once weaker evidence about the cause than isolating one change and retesting?
Model limits: Compares two named faulty counter models with a fixed correct model. A successful test set is not a proof that arbitrary code is correct.