Measure overlap without double counting
Implement span_coverage(root, children) where each interval is (start,end) in integer milliseconds. Return {"root_ms": duration, "covered_ms": union_length, "uncovered_ms": remainder}. Children may overlap or be empty, and zero-length intervals are allowed. Reject reversed intervals and children outside the root. Compute the union rather than adding durations. The child union is coverage of this local timeline, not a complete distributed critical-path algorithm.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
Input(0,100), [(10,60),(40,80)]
Output{"root_ms":100,"covered_ms":70,"uncovered_ms":30}
Input(5,5), []
Output{"root_ms":0,"covered_ms":0,"uncovered_ms":0}
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor