Advertisement
MaxDvc

matrixDiagonal

Dec 13th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. def matrixDiagonal(matrix,x,y):
  2. #@param:
  3. #   matrix: matrix;
  4. #   k: int;
  5.     assert matCheck(matrix), "Matrix is not square."
  6.     assert x<len(matrix) and y<len(matrix) and x>=0 and y>=0
  7.     i = 0
  8.     while i<len(matrix)-x and i<len(matrix)-y:
  9.         matrix[x+i][y+i] = 0
  10.         i += 1
  11.  
  12. def matCheck(matrix):
  13. #@param:
  14. #   matrix: matrix;
  15. #   return: bool;
  16.     lenght = len(matrix)
  17.     for i in range(0,lenght):
  18.         if len(matrix[i]) != lenght:
  19.             return False
  20.     return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement