Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. class Solution:
  2. @staticmethod
  3. def good_matrix(matrix: [[]]) -> bool:
  4. row, col = len(matrix), len(matrix[0])
  5. for b in range(row):
  6. for a in range(b, col):
  7. if matrix[row - 1 - b][col - 1 - a] != matrix[b][a]:
  8. return False
  9. return True
  10.  
  11. if __name__ == "__main__":
  12. S = Solution()
  13. A = [[1, 2, 3], [5, 4, 5], [3, 2, 1]]
  14. B = [[1, 2, 3], [5, 4, 5], [3, 2, 0]]
  15. C = [[1, 2, 3, 4], [4, 3, 2, 1]]
  16. E = [[1, 2, 3, 4, 6], [4, 3, 2, 1, 6]]
  17. D = [[]]
  18. assert (S.good_matrix(A) is True)
  19. assert (S.good_matrix(B) is False)
  20. assert (S.good_matrix(C) is True)
  21. assert (S.good_matrix(D) is True)
  22. assert (S.good_matrix(E) is False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement