Min-Max Matrix X67791


Statement
 

pdf   zip

html

Given a square matrix M of n× n (with n≥ 1) of integers, its matrix minMax is the matrix mM of n× 2 such that for all i (with 0≤ i<n), mM[i][0] is the minimum element of the i-th row of M and mM[i][1] is the maximum element of the i-th column of M.

For instance, if M = [[1,2,3], [3,1,2], [2,3,1]], mM = [[1,3], [1,3], [1,3]]

Implement the min_Max(M) function that given the square matrix M returns its minMax matrix.

You can use the min() and max() functions of Python, that given a list, they return their minimum and maximum element respectively.

Sample session
>>> min_Max([[1,2,3],[3,1,2],[2,3,1]])
[[1, 3], [1, 3], [1, 3]]
>>> min_Max([[100]])
[[100, 100]]
>>> min_Max([[2,2],[2,2]])
[[2, 2], [2, 2]]
>>> min_Max([[17, 4],[1,1]])
[[4, 17], [1, 4]]
>>> min_Max([[5, 1, 2, 1, -2],[1,21,-1,-2,8],[2,3,1,6,6],[1,2,3,4,5]])
[[-2, 5], [-2, 21], [1, 3], [1, 6]]
Information
Author
Language
English
Translator
Original language
Catalan
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python