Given a square matrix
of integers, with size
,
its matrix minMax is a matrix
with size
such that for all
,
element mM[i][0] is the minimum element of the
-th
row of
and mM[i][1] is the maximum element of the
-th
column of
.
For instance, if M is the matrix
1 2 3
6 7 4
8 9 5
then mM will be:
1 8
4 9
5 5
Implement a function minMax(M) that given a square
matrix M returns its minMax matrix.
You can use the python min and max
functions to compute the maximum and minimum of a list.
Only the function is expected. Remember to comment out any testing main program you may have.
>>> minMax([[1, 2, 3], [6, 7, 4], [8, 9, 5]]) [[1, 8], [4, 9], [5, 5]] >>> minMax([[1, 2, 3], [3, 2, 1], [2, 3, 1]]) [[1, 3], [1, 3], [1, 3]] >>> minMax([[100]]) [[100, 100]] >>> minMax([[2, 10], [5, 1]]) [[2, 5], [1, 10]] >>> minMax([[14, 4], [1, 1]]) [[4, 14], [1, 4]] >>> minMax([[5, 2, 1, -2], [21, -1, -3, 8], [2, 3, 6, 6], [1, 2, 4, 5]]) [[-2, 21], [-3, 3], [2, 6], [1, 8]]