Workspace/Coding labs
Loading progress

Invalidate stale checkpoints

Intermediate50 min

Implement resume_plan(dependencies, checkpoint, versions). A stored entry has a version and may have any result, including None. A node can be reused only if a checkpoint entry exists, its version matches, and every predecessor is reusable. Return sorted reuse and rerun lists. Ignore obsolete checkpoint nodes. Require versions to describe exactly the graph nodes; reject unknown dependencies and cycles. This plans pure computations only; external effects need separate reconciliation.

Your task

  1. Complete the starter function using the contract above.
  2. Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
  3. Run tests to record your result, then compare with the explained reference solution.

Examples

EXAMPLE 1

Inputa -> b -> d; a version changed; independent c unchanged

Outputreuse=[c], rerun=[a,b,d]

A changed dependency invalidates downstream work.
EXAMPLE 2

InputAll versions match and all entries exist

OutputAll nodes reusable

No computation needs to repeat.
solution.pyPython 3.12