We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I came up with this solution based on your explanation.
def flippingMatrix(matrix):
l = len(matrix)-1
num_groups = (len(matrix)**2)/4
iterator = int(num_groups**(1/2))
groups = []
for i in range(iterator):
for j in range(iterator):
groups.append([matrix[i][j], matrix[i][l-j], matrix[l-i][j], matrix[l-i][l-j]])
maxs = []
for i in range(len(groups)):
maxs.append(max(groups[i]))
return sum(maxs)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Flipping the Matrix
You are viewing a single comment's thread. Return to all comments →
I came up with this solution based on your explanation.
def flippingMatrix(matrix):