Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C 1.6 queens: (N+1)-queens Write a program queens that implements part of the search process for solving the N-queens problem. queens has one required

Using C

image text in transcribed

image text in transcribed

1.6 queens: (N+1)-queens Write a program queens that implements part of the search process for solving the N-queens problem. queens has one required argument and two optional arguments. The required argument will always occur last: it is the name of a file containing a chessboard. The two optional arguments may occur individually or together in any order. They are +2, which indicates that queens should report whether two queens may be placed on the board (Part 2), and , which allows for the presence of warrior queens (Part 3) This portion of the assignment has three parts, two of which are required. The third part will be counted as extra credit. Background A chessboard is an 8 8 grid of squares, each of which may contain up to one chess The queen is the most powerful piece in chess, capable of moving any number of squares vertically horizontally, or diagonally, provided that it does not change direction during the move. The N-queens problem asks how many ways N queens can be arranged on a board such that no queen can take another. That is, no queen can be moved to a square occupied by another queen in a single move. Part 1 Your program will be given a chessboard with some number of queens already placed. Your program must first determine whether any queen can take any other queen. If so, it wil print Invalid. If not, it will determine, for each empty square, whether a queen placed there could be taken by any other qeIt will print a new chessboard with these available squares marked with q Part 2 When 2 is given, your program will further determine if there is any way to place two additional queens on the board such that no queen can take any other qeen. If this is possible queens will print Tvo or more. If only one queen may be placed, queens will print One. If no queens may be placed, queens will print Zero. Part 3 (Extra creditA wrior queen is a queen that fights on horseback, and thus may move like a queen or like a knight. The knight moves in an L-shape: two squares horizontally and one square vertically, or two squares vertically and one square horizontally. Thus, a warrior queen may reach up to eight squares that a regular queen in the same position could not When -w is given, queens will consider boards that may contain warrior queens and distinguish between squares where a warrior queen may be placed (marked w) and squares where only a regular queen may be placed (marked q). Additionally, queena will accept chessboards containing warrior queens Input format The input will contain a chessboard, specified as eght lines containing cight characters. A indicates an empty space, and a Q indicates a qeen A W indicates a warrior queen. Behavior is unspecified if the chessboard contains a warrior queen, but the - option has not been given. Your program will not be tested with incorrectly formatted chessboards. 1.6 queens: (N+1)-queens Write a program queens that implements part of the search process for solving the N-queens problem. queens has one required argument and two optional arguments. The required argument will always occur last: it is the name of a file containing a chessboard. The two optional arguments may occur individually or together in any order. They are +2, which indicates that queens should report whether two queens may be placed on the board (Part 2), and , which allows for the presence of warrior queens (Part 3) This portion of the assignment has three parts, two of which are required. The third part will be counted as extra credit. Background A chessboard is an 8 8 grid of squares, each of which may contain up to one chess The queen is the most powerful piece in chess, capable of moving any number of squares vertically horizontally, or diagonally, provided that it does not change direction during the move. The N-queens problem asks how many ways N queens can be arranged on a board such that no queen can take another. That is, no queen can be moved to a square occupied by another queen in a single move. Part 1 Your program will be given a chessboard with some number of queens already placed. Your program must first determine whether any queen can take any other queen. If so, it wil print Invalid. If not, it will determine, for each empty square, whether a queen placed there could be taken by any other qeIt will print a new chessboard with these available squares marked with q Part 2 When 2 is given, your program will further determine if there is any way to place two additional queens on the board such that no queen can take any other qeen. If this is possible queens will print Tvo or more. If only one queen may be placed, queens will print One. If no queens may be placed, queens will print Zero. Part 3 (Extra creditA wrior queen is a queen that fights on horseback, and thus may move like a queen or like a knight. The knight moves in an L-shape: two squares horizontally and one square vertically, or two squares vertically and one square horizontally. Thus, a warrior queen may reach up to eight squares that a regular queen in the same position could not When -w is given, queens will consider boards that may contain warrior queens and distinguish between squares where a warrior queen may be placed (marked w) and squares where only a regular queen may be placed (marked q). Additionally, queena will accept chessboards containing warrior queens Input format The input will contain a chessboard, specified as eght lines containing cight characters. A indicates an empty space, and a Q indicates a qeen A W indicates a warrior queen. Behavior is unspecified if the chessboard contains a warrior queen, but the - option has not been given. Your program will not be tested with incorrectly formatted chessboards

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

Students also viewed these Databases questions

Question

What properties of agar make it ideal for use in culture media?

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago