N Queens Puzzle and Solution

N Queens Puzzle and graphical solution for an N*N chessboard.
143 descargas
Actualizado 5 dic 2019

Ver licencia

N Queens Puzzle is the problem of placing N queens on a chessboard in such a way that none of the queens threaten each other: only one queen in each row, column and diagonal. The problem was first put forward in 1848 just looking at 8 queens and solved by 1850 where the idea of the N queens on an N*N board was brought forward as an extension to the problem.

This code creates an N*N chessboard using the Chessboard.m function. The Queens.m script then solves the problem by placing the queens in unique rows and columns. The code then checks to see if any queens have been placed in the same diagonal and restarts if that is the case, choosing a new placement for all queens. This is a light brute forcing of a solution.

Citar como

Martin Thomas (2024). N Queens Puzzle and Solution (https://www.mathworks.com/matlabcentral/fileexchange/73566-n-queens-puzzle-and-solution), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2019b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Read, Write, and Modify Image en Help Center y MATLAB Answers.

Community Treasure Hunt

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

Start Hunting!
Versión Publicado Notas de la versión
1.0.0