Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- @staticmethod
- def good_matrix(matrix: [[]]) -> bool:
- row, col = len(matrix), len(matrix[0])
- for b in range(row):
- for a in range(b, col):
- if matrix[row - 1 - b][col - 1 - a] != matrix[b][a]:
- return False
- return True
- if __name__ == "__main__":
- S = Solution()
- A = [[1, 2, 3], [5, 4, 5], [3, 2, 1]]
- B = [[1, 2, 3], [5, 4, 5], [3, 2, 0]]
- C = [[1, 2, 3, 4], [4, 3, 2, 1]]
- E = [[1, 2, 3, 4, 6], [4, 3, 2, 1, 6]]
- D = [[]]
- assert (S.good_matrix(A) is True)
- assert (S.good_matrix(B) is False)
- assert (S.good_matrix(C) is True)
- assert (S.good_matrix(D) is True)
- assert (S.good_matrix(E) is False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement