Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Learn through experiments

Test the whole input contract

Which tests expose a missing input guard?

Entering midway? Revisit Make a passing test suite reveal a bug for the preceding worked example, or start here and use the explanation below.

1 · Try

Start with a concrete question

A synthetic quote function charges 3×quantity+2 for positive quantities and zero otherwise. Its buggy version applies the formula to every quantity.

Try the initial inputs, then write a prediction before changing one setting. All calculations run locally on your CPU.

Go directly to the experiment · Review basic mathematics

2 · Predict

What do you expect?

Predict whether tests at quantities 2 and 4 can prove behavior at zero.

3 · Experiment

Change one thing. Inspect what happens.

  1. Run positive-only tests and explain their coverage gap.
  2. Add zero and negative cases separately.
  3. Implement the repaired function and print pass/fail for at least five cases, including an unseen positive input.
Experiment inputs
Inputs
Your settings
Mechanism
Calculation below
Evidence
Compare outcomes
Passing tests2
Failing tests0
Test cases2

Compare the current results

Every bar starts at zero and uses the same numeric scale in this chart. The upper bound automatically adjusts to the largest current value (at least 1), so compare the numbers when changing inputs. Units and quantities come from each label; different kinds of quantity are not interchangeable. Displayed values are rounded to at most six significant digits.
02
  • Pass count2
    Pass count: 2Horizontal bar from zero to 2, on the shared zero to 2 numeric axis.
  • Fail count0
    Fail count: 0Horizontal bar from zero to 0, on the shared zero to 2 numeric axis.

Follow the calculation

  1. Quantity 2: contract 8, actual 8 → PASS.
  2. Quantity 4: contract 14, actual 14 → PASS.

The tool contract charges zero for nonpositive quantities. Positive-only examples cannot expose the missing guard.

Implement a function and independent test oracle

Repair quote using the contract. Keep the expected array independent of the function. Five true outputs mean these five tests passed; add a fresh case and its independently calculated expected value.

195/8,000 characters. Drafts save locally and are included in backups. Importing or opening a draft never runs it.

Bounded JavaScript subset: variables, primitive arrays, conditions, loops, functions and print. No browser objects, network, imports or eval. Maximum 10,000 operations, 64 array items, call depth 16, strings of 256 characters, 40 output lines / 4,000 output characters and 160 trace frames.

Compare with my earlier draft
function quote(q) { return 3 * q + 2; }
const inputs = [-2, 0, 1, 4, 7];
const expected = [0, 0, 5, 14, 23];
for (let i = 0; i < inputs.length; i++) {
  print(quote(inputs[i]) === expected[i]);
}

Explain what you changed and why in your observation notes. Text differences do not establish quality.

Inspect an example solution after your attempt
function quote(q) {
  if (q <= 0) { return 0; }
  return 3 * q + 2;
}
const inputs = [-2, 0, 1, 4, 7];
const expected = [0, 0, 5, 14, 23];
for (let i = 0; i < inputs.length; i++) {
  print(quote(inputs[i]) === expected[i]);
}

This is one worked example. Test another input and explain its limitations.

Captures keep your inputs, prediction and observation. Results are recalculated from those inputs. Resetting inputs keeps your captures and challenge history.

4 · Understand

Explain the mechanism

Test the whole input contract

A synthetic quote function charges 3×quantity+2 for positive quantities and zero otherwise. Its buggy version applies the formula to every quantity.

Predict before changing inputs

Predict whether tests at quantities 2 and 4 can prove behavior at zero.

Understand the mechanism

Partition an input space by behavior. Positive, zero and negative inputs trigger different obligations in this contract.

The formula returns 2 at quantity zero, but the contract requires 0. At −2 it returns −4, also invalid.

A test oracle is the expected answer derived independently from the contract. Copying the implementation formula into every expected answer would repeat the same bug.

Calculate it yourself

quote(q)=0 when q≤0; otherwise quote(q)=3q+2.

Guided investigation

  1. Run positive-only tests and explain their coverage gap.

  2. Add zero and negative cases separately.

  3. Implement the repaired function and print pass/fail for at least five cases, including an unseen positive input.

Assumptions and limitations

  • The model accepts bounded integer examples only. A real interface must also address nonnumbers and missing data.

  • Passing the fixture does not establish total correctness; the independent implementation task requires broader evidence.

Further investigations

High school: Write a table of inputs, expected outputs and reasons before coding.

College: Add invariant tests and compare against a separately authored oracle.

Working professionals: Produce a regression test and failure report for an input-validation defect.

Your implementation or data task

Repair quote using the contract. Keep the expected array independent of the function. Five true outputs mean these five tests passed; add a fresh case and its independently calculated expected value.

Use the editable workspace on this page. Its output is practice evidence; explain why it satisfies the contract and test a fresh case.

5 · Apply

Try a fresh case

Under the same contract, what is the quote for a previously untested quantity of 7?

This is a public practice check. Retries support learning; matching a number does not certify independent proficiency.

Take the investigation further

Choose any extension. These are project prompts for you to carry out; they are not automatically assessed.

School investigation

Write a table of inputs, expected outputs and reasons before coding.

College investigation

Add invariant tests and compare against a separately authored oracle.

Workplace investigation

Produce a regression test and failure report for an input-validation defect.

6 · Continue

Keep the evidence, choose your next step

Completion records your own decision that you have worked through this investigation. Practice checks and independent project evidence are separate.