[Indices] = NTowersPuzzle( [entry]);
[Indices Board] = NTowersPuzzle( [entry]);
NTowersPuzzle( [empty] or [invalid] ) => default
NTowersPuzzle( P ) => startposition is (P, P)
NTowersPuzzle( L, C) => startposition is (L, C)
NTowersPuzzle( L, C, N) => startposition is (L, C) on N-by-N board
This is my very limited version of the Eight Queens Puzzle (chess).
It produces a N-number Towers on a N-by-N chess board, ence the name.
The board is considered to be a N-by-N matrix.
The pieces positions are signed by ONEs and the positions without pieces
are signed by ZEROs.
The user is allowed to decide the position of the starting piece.
If not empty or invalid input, the default board size is 8-by-8.
If starting piece position is invalid, it produces random position.
The function itself may return two different arguments:
the first is a vector with the coordinates of the pieces;
the second is the matrix with signed position of the pieces.
It prints the coordinates and the board.
@ ACx // Janeiro 2013
ACLNM (2023). N Towers Puzzle (https://www.mathworks.com/matlabcentral/fileexchange/40106-n-towers-puzzle), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!