Write a function zdiag(m) that receives a square matrix of integers m and checks whether the elements along the main diagonal of m are all zeros. If they are all zeros indeed, the function must return zero. If there are nonzeros somewhere in the main diagonal, the function must return the nonzero value appearing there that has smallest coordinates.
Observation
You can safely assume only that the rows of the matrix are either tuples or lists, and that the matrix itself is either a tuple of rows or a list of rows.
>>> zdiag([(0, 1), (-1, 0)]) 0 >>> 100 == zdiag(([0, 1, 2], [7, 0, -7], [102, 101, 100])) True >>> zdiag([]) 0