Compare scan rows
Your task
A press operator compares two scans of the same calibration sheet, one taken before a maintenance stop and one after. Each scan is a grid of single character ink codes, one code per cell, and the two scans need not even agree on how many rows they have. A row matches when both scans have that row, the two rows hold the same number of cells, and every cell carries the same code. The scanner writes '?' for a cell it could not read, and a '?' on either side never counts as a difference. Return the index of the lowest numbered row that does not match. A row that only one scan has counts as a difference. Return -1 when every row matches. Codes are case sensitive.
Examples
first_mismatch_row(before: list[list[str]], after: list[list[str]]) -> intExample 1
Input
first_mismatch_row([["k", "k"], ["k", "m"]], [["k", "k"], ["k", "m"]])Output
-1Example 2
Input
first_mismatch_row([["a", "b", "c"], ["d", "e", "f"]], [["a", "b", "c"], ["d", "x", "f"]])Output
1Example 3
Input
first_mismatch_row([["a", "?"], ["b", "b"]], [["a", "z"], ["b", "c"]])Output
1