Trace parcel deflectors
A parcel sorter routes packages over a grid of fixed deflectors, one deflector per cell. A cell holds '>' to push a parcel one cell right, '<' one cell left, '^' one cell up, 'v' one cell down, or 'O' for a chute that drops the parcel out of the machine. A parcel is placed on the cell at start_row and start_col, then follows whatever deflector it lands on. Return how many cells the parcel rests on, counting the one it starts on. The run ends at a chute, which counts, or when a deflector pushes the parcel off the belt, which does not. Return -1 when the parcel reaches a cell it has already rested on, since it then circles forever. Return 0 when the belt has no cells, or when the start is off the belt. Every row has the same width.
sorter_path_length(belt: list[list[str]], start_row: int, start_col: int) → int[[[">",">","O"]],0,0]out3[[[">","<"]],0,0]out-1[[["^","O"]],0,0]out1State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[[">",">","O"]],0,0]3not run yetsample[[[">","<"]],0,0]-1not run yetsample[[["^","O"]],0,0]1not run yetsample