Question: 2) N-Queens. A Queen on a chessboard can attack any piece in the same column, row or diagonal. The N-Queens problem is to place n

2) N-Queens. A Queen on a chessboard can attack any piece in the same column, row or diagonal. The N-Queens problem is to place n queens on anxn chessboard such that no two queens threaten each other. a) Implement a one-dimensional integer array of Queen positions for an 8x8 board where indices represent rows and the values represent columns For example, this "safe" solution would be (3,6,2,7,1,4,0,5) b) Request values for the array from the console. c) Implement an output to display the board (see output example). d) Implement a queensAreSafe function that: 1) Returns false if multiple queens share a column. Note that by design they are in separate rows (make sure you understand why) 2) Returns false if multiple queens share a diagonal. 3) Returns true if all queens are safe. e) Program should display if the Queens are safe or not safe. Example output (input is bold and italicized) Enter 8 column values: 1 4 2 3 5 7 6 0 Queens are not safe
Step by Step Solution
There are 3 Steps involved in it
Heres a Python implementation for the NQueens problem ... View full answer
Get step-by-step solutions from verified subject matter experts
