The six edges, read straight off the formulas — including the one that makes this exercise exist: discount reads subtotal, because a threshold comparison is a read like any other. The exercise is this same page with an empty edge list.

The edges

Each formula reads exactly two values, so each contributes exactly two edges:

Formula Reads
subtotal = quantity × unitPrice quantity, unitPrice
discount = subtotal ≥ 1000 ? discountPercent : 0 subtotal, discountPercent
total = subtotal × (1 − discount / 100) subtotal, discount

The middle row is the trap. The ≥ 1000 comparison doesn't feel like a dependency — it's "just a condition" — but the condition's left-hand side is subtotal, so a subtotal change can flip the discount without discountPercent moving at all. Once that edge is on paper, the derived dirty sets say what every handler must really do:

When this input changes… …these must be recomputed
quantity subtotal, discount, total
unitPrice subtotal, discount, total
discountPercent discount, total

Notice what just happened: the machine derived the transitive closure from six local facts. The imperative style asks each handler author to derive it in their head instead — and to re-derive it every time any formula changes. That asymmetry is the entire course.

Live and green

Press Run — the full edge list, the derived dirty sets, six of six.

List the six direct dependency edges of the quote calculator — subtotal reads quantity and unitPrice, discount reads subtotal and discountPercent, total reads subtotal and discount — derive each input's transitive dirty set from them, and show the battery all green.

← Back to the exercise · Lesson 1 — The combinatorial trap · All solutions

Reconnecting…
The connection to the server was interrupted. Trying to restore it…
Trying again…
The connection could not be restored. Reloading the page…
The server was updated. Reloading the page to pick up the latest version.