File Exchange

image thumbnail

N Queens Puzzle with Solution

version 1.0.0 (1.34 KB) by Matin Dehghani
n queens problem in n*n chessboard

246 Downloads

Updated 17 Nov 2018

View License

What is 8 queens puzzle?!
The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other.
Thus, a solution requires that no two queens share the same row, column, or diagonal. The eight queens puzzle is an example of the more general n queens problem of placing n non-attacking queens on an n×n chessboard, for which solutions exist for all natural numbers n with the exception of n=2 and n=3....
https://en.wikipedia.org/wiki/Eight_queens_puzzle

-------------------------------------------------------------------------------------------
Tips:
1) Run .m file and insert the board size (that is also number of queens).
2) There is not a unique solution for every size of board so every time you run the program you may see a new solution.

HELP ME to improve it :
mail: matin99dehghani@gmail.com
Telegram: t.me/matlab_ph

Please share your idea in comments

Cite As

Matin Dehghani (2021). N Queens Puzzle with Solution (https://www.mathworks.com/matlabcentral/fileexchange/69461-n-queens-puzzle-with-solution), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!