Queens and Knights You are given a 8×8 chess board with out any pieces other than equal number of queens and knights. You have to place an equal number of knights and queens on the chessboard such that NO piece attacks any other piece. Each position in the board uses following to represent the status: 0 – no pieces, 1 – queens, 2 – knights. Given a board with or without any pairs of queen and knight, you have to write a function addMaxPieces which adds as many pairs of queens and knights as possible and returns the updated board in the same format will writing service derby .

You can use the fact that in the best configuration, a maximum of 5 queens and 5 knights can be placed on 8 x 8 board such that NO piece attacks any other piece. An example of such a configuration is given below . Note that you will get 50% credit, if you add even one extra pair of queen and knight on the board correctly. Instructions to use Open PBT Client: 1. Specify the work directory path in the ‘Work Directory Path’ field. The path should correspond to your solution work directory. 2. Download the Support files by clicking the Get Support Files . 3. You will find the problem directories containing: problem. h file * problem. c file in your work directory. 4. Write your solution in . c file Step 1: In your Solution File: 1. Add method public static int[][] addMaxPieces(int[][] board) Step 2: 1. Pass the following parameter to the method addMaxPieces() board is a two dimension integer array, represents the chess board as mentioned in the problem description. Step 3: Write the appropriate code as mentioned in the problem description by following the below given Constraints. 1. The input should be the two dimension integer array provided to the method with some entries in the atrix. 2. The entries specify the position of the Queens and Knights in the chess board (matrix). 1 for Queen and 2 for Knight 3. You need to figure out the position of the Queens and Knights in the chess board, which can be additionally added to the board so thus no peices will attack anyone 4. Your method should return the chess board that is the two dimension array with some additional entries. 5. If your method will able to add atleast one pair of Queens and Knights, you will get the 50% credit. 6. Read Constraints carefully. The Prototype of the Function is : int** addMaxPieces(int** board) takes a chess board as input and tries to add as many knight and queen pairs as possible and return the board in same format. Constraints * The positions on the board can have only 0,1,2 values, else return the board as it is. * Input board should have equal number of queens and knights (if any), else return the board as it is. * In Input Board, no piece can attack any other piece, else return the board as it is. * Input board should be of size 8 x 8, else return the board as it is. Example 1 Input board[0][2] = board[1][5] = board[2][1] = 1; board[6][4] = board[6][7] = board[7][3] = 2; Output

The function returns X,Y = 0,2 Piece = Q input X,Y = 1,5 Piece = Q input X,Y = 2,1 Piece = Q input X,Y = 3,6 Piece = Q X,Y = 5,0 Piece = Q X,Y = 7,7 Piece = K X,Y = 6,4 Piece = K input X,Y = 6,7 Piece = K input X,Y = 7,3 Piece = K input X,Y = 7,4 Piece = K The picture for this example . Example 2 Input board[0][2] = board[1][5] = 1; board[6][4] = board[6][7] = 2; Output The function returns X,Y = 0,2 Piece = Q input X,Y = 1,5 Piece = Q input X,Y = 2,1 Piece = Q X,Y = 3,6 Piece = Q X,Y = 5,0 Piece = Q X,Y = 7,7 Piece = K X,Y = 6,4 Piece = K input X,Y = 6,7 Piece = K input X,Y = 7,3 Piece = K

X,Y = 7,4 Piece = K Example 3 Input board[0][2] = 1; board[6][4] = 2; Output The function returns X,Y = 0,2 Piece = Q input /> X,Y = 1,5 Piece = Q X,Y = 2,1 Piece = Q X,Y = 3,6 Piece = Q X,Y = 5,0 Piece = Q X,Y = 7,7 Piece = K X,Y = 6,4 Piece = K input X,Y = 6,7 Piece = K X,Y = 7,3 Piece = K X,Y = 7,4 Piece = K For C solutions Header File | : | queenknights. h | Function Name | : | int** addMaxPieces(int** board) | Directory Name | : | queenknights | File Name | : | queenknights. c | For C++ solutions Header File | : | queenknights. h | Class Name | : | QueenKnights | Function Name | : | int** addMaxPieces(int** board) |

Directory Name | : | queenknights | FileName | : | queenknights. cpp | General Instructions * | The file / class names, functions, method signatures, header files to be used are mentioned in the problem statement. Do not use your own names or change the method signatures and fields. You can add any number of additional methods. | * | Do not forget to mention the file extension, either . c or . cpp as the case maybe. | * | For C solutions, change the value of “C_OR_CPP” macro in header file to 1 and for C++ solutions change the value to 2. | * | Incase of iostream. h specify as iostream only. |