Objective
With enough workers, independent tasks run at the same time, but a task cannot start until the ones it depends on have finished. The minimum time is set by the critical path: the longest chain of dependencies. Real threads cannot be created in the browser, so the program simulates the situation in a deterministic way.
Instructions
- Read
nand thennlines withname duration dependencies, wheredependenciesare the dependencies separated by commas, or-if it has none. The dependencies of a task always appear in earlier lines. - Each task starts as soon as the last of its dependencies finishes (or at 0 if it has none) and lasts its duration. Show
name: start s, end ffor each one, in input order. - The cause of a task starting so late is the dependency that finishes latest (if tied, the first in the list).
- At the end, the task that finishes latest (if tied, the first in input order) closes the critical path: follow its causes backwards. Show
Minimum duration: TandCritical path: a -> b -> c, from the first to the last task.
4
a 3 -
b 2 a
c 4 a
d 1 b,c
a: start 0, end 3
b: start 3, end 5
c: start 3, end 7
d: start 7, end 8
Minimum duration: 8
Critical path: a -> c -> d
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise