Design (in OOP code) a system similar to VS Code that tracks when functions/code blocks are opened and closed.
Asked in the First technical stage stage. Candidate did not pass this round.
Implement track_code_blocks(events). Each event is a dictionary with type ("open" or "close"), name, and integer position. Events are properly nested and ordered by position. An open event starts a block, and a close event completes the most recently opened block. Return completed blocks in opening order, each as {name, start, end, depth}, where depth is zero-based.
def track_code_blocks(events):