Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve using MATLAB. Write a function EightQueens(strArr). The input will be an array of the locations of eight queens on a standard 8x8 chess

Please solve using MATLAB. Write a function EightQueens(strArr). The input will be an array of the locations of eight queens on a standard 8x8 chess board. The structure of the strArr will be: ["(x,y)", "(x,y)", ...] where (x,y) represents the position of the current queen on the chessboard (x and y will both range from 1 to 8 where 1,1 is the top-left of the chessboard and 8,8 is the bottom-right). There will be no other pieces on the board.

Your program should determine if all the queens are placed in such a way that none of them are in a position to attack another (see example below). If this is true, then return the string true, else return false. (Optional) If false, return the last queen in the list that is attacking another piece in the original formatting (x,y).

For example: if strArr is ["(2,1)", "(4,2)", "(6,3)", "(8,4)", "(3,5)", "(1,6)", "(7,7)", "(5,8)"] then your program should return the string true.

image text in transcribed

using either Matlab or Python, write a function EightQueens strArr). The input will be an array of the locations of eight queens on a standard 8 8 chess board. The structure of the strArr will be: x y .y . J where (x.y) represents the position of the current queen on the chessboard (x and y will both range from 1 to 8 where 1,1 is the top-left of the chessboard and 8,8 is the bottom-right). There will be no other pieces on the board. Your program should determine if all the queens are placed in such a way that none of them are in a position to attack another (see example below). If this is true, then return the string true, else return false. (Optional) If false, retum the last queen in the list that is attacking another piece in the original formatting "(x,y)" For example: if strArr is ["(2,1)", (4,2)", "(6,3)", "(8,4)", "(3,5, "(1,6)", (7,7), "(5,8)'1 then your program should return the string true

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

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago