ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Sudoku.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*----------------------------- File Sudoku.h ------------------------------*/
3/*--------------------------------------------------------------------------*/
29/*--------------------------------------------------------------------------*/
30/*----------------------------- DEFINITIONS --------------------------------*/
31/*--------------------------------------------------------------------------*/
32
33#ifndef __ADS_Sudoku
34 #define __ADS_Sudoku
35/* self-identification: #endif constant */
36
37/*--------------------------------------------------------------------------*/
38/*------------------------------ INCLUDES ----------------------------------*/
39/*--------------------------------------------------------------------------*/
40
41#include <cstddef>
42#include "ADS/Contract.h"
43
44#include <vector>
45
46/*--------------------------------------------------------------------------*/
47/*--------------------------- NAMESPACE ------------------------------------*/
48/*--------------------------------------------------------------------------*/
49
50namespace ADS
51{
52
53using Grid = std::vector< std::vector< int > >;
54
74inline bool check( const Grid & S , std::size_t x , std::size_t y , int c );
75
102inline bool sudoku( Grid & S , std::size_t i = 0 );
103
104/*--------------------------------------------------------------------------*/
105
106} // end( namespace ADS )
107
108/*--------------------------------------------------------------------------*/
109/*-------------------------- IMPLEMENTATION --------------------------------*/
110/*--------------------------------------------------------------------------*/
111
112#include "ADS/backtrack/impl/Sudoku.tpp"
113
114/*--------------------------------------------------------------------------*/
115
116#endif /* Sudoku.h included */
117
118/*--------------------------------------------------------------------------*/
119/*--------------------------- End File Sudoku.h ----------------------------*/
120/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
bool sudoku(Grid &S, std::size_t i=0)
fills the empty squares of from the square number on, in the order of the rows; true if it can
bool check(const Grid &S, std::size_t x, std::size_t y, int c)
whether can be written in the square of , i.e., it is not on its row, its column or its block
Definition ADT.h:96
std::vector< std::vector< int > > Grid
the squares, 0 empty
Definition Sudoku.h:53