You are given a 8x8 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.
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
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 matrix. 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...