Mr_HO1A

Custom Chess Board Question

Oct 15th, 2018
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1.  
  2. def isValidBoad(board, N):
  3.     rows, colums = N, N
  4.     for row in range(0, rows - 1):
  5.         for col in range(0, colums - 1):
  6.             currentCell = board[row][col]
  7.             if board[row][col + 1] == currentCell or board[row + 1][col] == currentCell:
  8.                 return False
  9.     return True
  10.  
  11.  
  12. def main():
  13.     T = int(input())
  14.     boards = []
  15.     for _ in range(T):
  16.         Dim = int(input())
  17.         board = [[0 for x in range(Dim)] for _ in range(Dim)]
  18.         for x in range(Dim):
  19.             board[x] = list(map(int,input().split(" ")))
  20.         boards.append(board)
  21.     for board in boards:
  22.         size = len(board)
  23.         if isValidBoad(board,size) == True:
  24.             print("Yes")
  25.         else:
  26.             print("No")
  27.  
  28.  
  29. main()
Add Comment
Please, Sign In to add comment