Your question is End-to-End Debugger Simulation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
For an HRT-style debugging trace, a program has executable lines numbered from 1 through total_lines. The debugger starts stopped at line 1. Given sorted breakpoint locations and a sequence of commands, simulate execution and return the final line where the debugger stops.
A next command advances execution by exactly one line. A continue command advances to the first breakpoint strictly greater than the current line. If no such breakpoint exists, it advances directly to total_lines. Once the debugger reaches total_lines, all later commands leave it there.
Breakpoints are unique and sorted in strictly increasing order.
Implement final_debug_line(total_lines, breakpoints, actions):
total_lines: integer, the last executable line.breakpoints: sorted list of integers identifying breakpoint lines.actions: list containing only the strings "next" and "continue".def final_debug_line(total_lines, breakpoints, actions):