Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
1 Problem descriptionMain objective: Solve the n queens problems. You have to place n queenson an n n chessboard such that no two attack each other. Important: thechessboard should be indexed startin
1 Problem description
Main objective: Solve the n queens problems. You have to place n queens
on an n n chessboard such that no two attack each other. Important: the
chessboard should be indexed starting from 1, in standard (x; y) coordinates.
Thus, (4; 3) refers to the square in the 4th column and 3rd row.
We have a slight twist in this assignment. We will take as input the position
of one queen, and have to generate a solution with a queen in this position.
Format: You should provide a Makele. On running make, it should create
\NQueens.jar". You should run the jar with two command line arguments:
the rst is an input le, the second is the output le. For example, we would
call the command java -jar NQueens.jar in.txt solution.txt. The le
in.txt will have inputs to the main program (as described below), and the le
solution.txt will have the desired solution.
Each line of the input le corresponds to a dierent instance. Each line of
the input le will have three integers: the chessboard size, the column where
the input queen is placed, and the row where the input queen is placed. For
example, the le may look like:
7 3 2
4 1 1
The rst line means we have a 7 7 chessboard, with one queen placed at
(3; 2). We wish to place 6 more queens without any attacking the other. The second line means we have a 4 4 chessboard, with one queen at (1; 1). We
wish to place 3 more queens without any attacks. So on and so forth.
Output: On running the command, the following should be printed in the
output le. For each line of the input le, there is a line in the output le with
the placement of queens.
• If there is no solution to the problem, print \No solution" (with a newline
at the end)
• If there is a solution, print the position of each queen as <column> <space>
<row> <space> followed by the position for the next queen. The positions
should be in increasing order of column, so rst column rst, second col-
umn second, etc. Please follow this format exactly, so that the checking
script works for you.
For example, the output for the input describe above could be
1 1 2 5 3 2 4 6 5 3 6 7 7 4
Observe how \3 2" is part of the rst solution, since we started with a queen
there. The solution is not unique, so your code might nd some other placement.
On the other hand, a 4 4 chessboard with a queen at (1; 1) has no solution.