N-queens problem: Difference between revisions
Content added Content deleted
Line 6,582: | Line 6,582: | ||
{{FormulaeEntry|page=https://formulae.org/?script=examples/N-queens_problem}} |
{{FormulaeEntry|page=https://formulae.org/?script=examples/N-queens_problem}} |
||
'''Solution''' |
|||
The following function: |
|||
* Is able to calculate solution for chessboards of any size (but it is slow for big chessboards) |
|||
* It does not detect rotated or reflected solutions |
|||
This is an example of backtracking: |
|||
[[File:Fōrmulæ - N-queens problem 01.png]] |
|||
[[File:Fōrmulæ - N-queens problem 02.png]] |
|||
[[File:Fōrmulæ - N-queens problem 03.png]] |
|||
'''Improvement.''' The following functions calls the previous one, but shows the solution on a more friendly way |
|||
[[File:Fōrmulæ - N-queens problem 04.png]] |
|||
[[File:Fōrmulæ - N-queens problem 05.png]] |
|||
[[File:Fōrmulæ - N-queens problem 06.png]] |
|||
=={{header|GAP}}== |
=={{header|GAP}}== |