Log inBook a Demo
BuildSeniorBackendAuto-graded

Order a graph so dependencies come before dependents

Write a topological sort that puts every dependency first and raises an error when the graph has a cycle.resolve_order(graph) takes a map from each node to its direct dependencies and should return an order where every dependency comes before the node that needs it. Each node appears exactly once, including nodes that only show up as a dependency and nodes with no links at all. If the graph has a cycle, it must raise CycleError. Any valid order is accepted.
45 min
python

What it measures

Topological orderingPutting every dependency before its dependent, through long chains, shared dependencies and wide fan-outs.
Cycle detectionRaising CycleError on cyclic graphs, self-loops included, without ever hanging.
Complete outputReturning every node exactly once, dependency-only and disconnected ones included.

Your environment

Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish

Start this lab

45 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo