Question: Write a function in Python (without using modules) that, given a M by N matrix and an integer k, if M by N matrix can

 Write a function in Python (without using modules) that, given a

Write a function in Python (without using modules) that, given a M by N matrix and an integer k, if M by N matrix can be divided by the k by k square matrix, returns the sum of maximum value of each square matrix. If not, returns0 Input: M by N matrix and an integer k Output: Sum of maximum values of each subregion (each k by k square matrix within the M by N matrix) Visual Depiction: Given a 4x4 matrix 1 1 2 4 5 6 7 8 3 2 10 1 234 and a square window of size 2x2, the subregions are: 11|24 5 6 78 3 2| 10 1 2134 The corresponding Max Pooled values for each subregions are: 6 8 So output is the sum of the max values of each subregion is 6+8+3+421 Examples: Example 1 Input: ([[20, 200, -13, 1341, [120, 32, -120, 12]1, 2) Example 1 Output: 320 200 and 120 are max's of given 2 x 4 matrix's two 2 x 2 square matrices Example 2 Input: ([[20, 200, -13, 134], [120, 32, -120, 1211, 4) Example 2 Output: "NONE' 2 x 4 matrix cannot be divided by 4 x 4 square matrix Example 3 Input: (I1 1 2 41,15 67 8],13 2 1 0], [1 2 3 411,2) Example 3 Output: 21

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!