Customized Chess Board

  • + 0 comments

    My Python approach :

    def solve(board):
        i = 0
        if(board[0][1] == 0):
            check = 0
        else:
            check = 1
        if(len(board) % 2 == 0):
            while(i < len(board)):
                if board[i][i] != (1 - check) or board[i][len(board) - 1 - i] != check:
                    return 'No'
                i += 1
        else:
            while(i < len(board)):
                if board[i][i] != (1 - check) or board[i][len(board)-1-i] != (1 - check):
                    return 'No'
                i += 1    
        i = 0
        while(i < len(board)-1):
            if(board[i][i+1] != check or board[i+1][i] != check):
                return 'No'
            i += 1
        return 'Yes'