How Many Rounds of Tool Calls

Hard data structure and algorithm practice puzzle.

An agent has n tool calls to make, numbered from 0, and some need another call's result first. Each pair [a, b] in deps means b needs a. Calls whose inputs are all ready can run at the same time, as one wave. Return the number of waves needed to run everything, or -1 if the plan is circular and can never finish. This is a topological sort that counts its levels.

Solve it three ways: snap the jigsaw pieces together, fill in the blanks, or type it from scratch against the tests. This one is free to play, with no account.

Every line of the solution comes with a note explaining why it is there, and a step by step replay shows the code running. At level 3, where you type it yourself, you can ask for an AI mock interview on this problem that ends with a hiring manager's scorecard.

Then grow it into a real project with the Software Engineer button: this puzzle becomes the Request Route Planner, a pipeline you can run and download. See every Software Engineer project.

More Applied ML/AI puzzles

All 33 Applied ML/AI practice problems

Browse all 676 puzzles