ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
NQueens.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*----------------------------- File NQueens.h -----------------------------*/
3/*--------------------------------------------------------------------------*/
30/*--------------------------------------------------------------------------*/
31/*----------------------------- DEFINITIONS --------------------------------*/
32/*--------------------------------------------------------------------------*/
33
34#ifndef __ADS_NQueens
35 #define __ADS_NQueens
36/* self-identification: #endif constant */
37
38/*--------------------------------------------------------------------------*/
39/*------------------------------ INCLUDES ----------------------------------*/
40/*--------------------------------------------------------------------------*/
41
42#include <bit>
43#include "ADS/Contract.h"
44
45#include <algorithm>
46#include <cstdint>
47#include <cstdlib>
48#include <stdexcept>
49#include <string>
50#include <vector>
51
52/*--------------------------------------------------------------------------*/
53/*--------------------------- NAMESPACE ------------------------------------*/
54/*--------------------------------------------------------------------------*/
55
56namespace ADS
57{
58
85template< class F >
86long nQueens( int n , F && f );
87
117template< class F >
118long nQueensIterative( int n , F && f );
119
131inline bool admissible( const std::vector< int > & Q );
132
136inline std::string board( const std::vector< int > & Q );
137
138/*--------------------------------------------------------------------------*/
139
140} // end( namespace ADS )
141
142/*--------------------------------------------------------------------------*/
143/*-------------------------- IMPLEMENTATION --------------------------------*/
144/*--------------------------------------------------------------------------*/
145
146#include "ADS/backtrack/impl/NQueens.tpp"
147
148/*--------------------------------------------------------------------------*/
149
150#endif /* NQueens.h included */
151
152/*--------------------------------------------------------------------------*/
153/*--------------------------- End File NQueens.h ---------------------------*/
154/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
long nQueens(int n, F &&f)
the placements of queens, f( Q ) on each, the column of the queen of the row , and true from f to s...
long nQueensIterative(int n, F &&f)
the placements of queens by the iterative backtracking, with the stage and the column of the queen...
std::string board(const std::vector< int > &Q)
the board of , a line per row, with the letter Q for a queen and a dot for an empty square
bool admissible(const std::vector< int > &Q)
whether no two queens of attack each other, the column of the queen of the row
Definition ADT.h:96