Prerequisites are a directed graph
Every question in this lesson hands you tasks, and pairs that say one task can't start until another has finished. Courses and the courses they require. Build steps. Spreadsheet cells and the cells their formulas read.
Each pair is an arrow from the prerequisite to the task that needs it
tasks = ["fetch", "compile", "assets", "test", "package", "docs", "deploy"]
needs = [
# compile needs fetch
("compile", "fetch"),
("assets", "fetch"),
("test", "compile"),
("package", "compile"),
("package", "assets"),
("deploy", "test"),
("deploy", "package"),
]
for task, prerequisite in needs:
print(f"{prerequisite} -> {task}")
fetch -> compile
fetch -> assets
compile -> test
compile -> package
assets -> package
test -> deploy
package -> deploy
Each pair is (task, prerequisite). The arrow runs the other way, from the prerequisite to the task that needs it, because that's the order things happen in: fetch finishes, and then compile can start. Drawn out, the pipeline looks like this:
docs is in no pair. It needs nothing, and nothing needs it.
This is a directed graph: the tasks are its nodes, and each pair is an edge, an arrow with a direction. On a grid, an edge went both ways. Here compile needs fetch, and fetch doesn't need compile.
The editor holds the pipeline's needs. Write arrows, which turns each pair into its arrow, and needed_by, which lists the tasks that a finished task releases.