Intermediate
Print a trace tree with self time
Spans are tuples (id, parent, name, start_ms, end_ms) in start order; a parent of 0 means the root. Write span_tree(spans) that returns a list of lines, one per span, indented two spaces per level of depth.
Each line is <name> total=<ms> self=<ms>, where self is total minus the total of the span's direct children.
What Check tests
- A single root span
- Children are indented and reduce the parent's self time
- Grandchildren are indented twice
- Only direct children are subtracted
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.