ADS
Algorithms and Data Structures
Toggle main menu visibility
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
56
namespace
ADS
57
{
58
85
template
<
class
F >
86
long
nQueens
(
int
n , F && f );
87
117
template
<
class
F >
118
long
nQueensIterative
(
int
n , F && f );
119
131
inline
bool
admissible
(
const
std::vector< int > & Q );
132
136
inline
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
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ADS::nQueens
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...
ADS::nQueensIterative
long nQueensIterative(int n, F &&f)
the placements of queens by the iterative backtracking, with the stage and the column of the queen...
ADS::board
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
ADS::admissible
bool admissible(const std::vector< int > &Q)
whether no two queens of attack each other, the column of the queen of the row
ADS
Definition
ADT.h:96
ADS
backtrack
NQueens.h
Generated by
1.17.0