Wafer rim failures
A chip fab records a wafer test map as a rectangular grid of single character codes, one code per die. Engineers care where the failures sit, because failures around the rim usually point at handling damage while failures in the middle point at the process itself. A die is on the rim when it sits in the first row, the last row, the first column or the last column of the map. Every other die is interior. Given wafer and the code mark that means a failed die, return exactly two numbers in this order: how many failed dies sit on the rim, then how many sit in the interior. A map with fewer than three rows, or fewer than three columns, has no interior at all. A map with no rows returns two zeros.
edge_defect_split(wafer: list[list[str]], mark: str) → list[int][[[".",".","."],[".","x","."],["x",".","."]],"x"]out[1,1][[["x","x","x","x"],["x","x","x","x"]],"x"]out[8,0][[[".",".","."],[".",".","."],[".",".","."]],"x"]out[0,0]State 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.
[[[".",".","."],[".","x","."],["x",".","."]],"x"][1,1]not run yetsample[[["x","x","x","x"],["x","x","x","x"]],"x"][8,0]not run yetsample[[[".",".","."],[".",".","."],[".",".","."]],"x"][0,0]not run yetsample