Algorithms_in_C++  1.0.0
Set of algorithms implemented in C++.
sudoku_solve.cpp File Reference

Sudoku Solver algorithm. More...

#include <iostream>
#include <array>
Include dependency graph for sudoku_solve.cpp:

Namespaces

 backtracking
 Backtracking algorithms.
 

Functions

template<size_t V>
bool backtracking::isPossible (const std::array< std::array< int, V >, V > &mat, int i, int j, int no, int n)
 
template<size_t V>
void backtracking::printMat (const std::array< std::array< int, V >, V > &mat, int n)
 
template<size_t V>
bool backtracking::solveSudoku (std::array< std::array< int, V >, V > &mat, int i, int j)
 
int main ()
 

Detailed Description

Sudoku Solver algorithm.

Sudoku (数独, sūdoku, digit-single) (/suːˈdoʊkuː/, /-ˈdɒk-/, /sə-/, originally called Number Place) is a logic-based, combinatorial number-placement puzzle. In classic sudoku, the objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids that compose the grid (also called "boxes", "blocks", or "regions") contain all of the digits from 1 to 9. The puzzle setter provides a partially completed grid, which for a well-posed puzzle has a single solution.

Author
DarthCoder3200
David Leal

Function Documentation

◆ main()

int main ( void  )

Main function

131  {
132  const int V = 9;
134  std::array <int, V> {5, 3, 0, 0, 7, 0, 0, 0, 0},
135  std::array <int, V> {6, 0, 0, 1, 9, 5, 0, 0, 0},
136  std::array <int, V> {0, 9, 8, 0, 0, 0, 0, 6, 0},
137  std::array <int, V> {8, 0, 0, 0, 6, 0, 0, 0, 3},
138  std::array <int, V> {4, 0, 0, 8, 0, 3, 0, 0, 1},
139  std::array <int, V> {7, 0, 0, 0, 2, 0, 0, 0, 6},
140  std::array <int, V> {0, 6, 0, 0, 0, 0, 2, 8, 0},
141  std::array <int, V> {0, 0, 0, 4, 1, 9, 0, 0, 5},
142  std::array <int, V> {0, 0, 0, 0, 8, 0, 0, 7, 9}
143  };
144 
145  backtracking::printMat<V>(mat, 9);
146  std::cout << "Solution " << std::endl;
147  backtracking::solveSudoku<V>(mat, 0, 0);
148 
149  return 0;
150 }
Here is the call graph for this function:
std::cout
std::array
STL class.
std::endl
T endl(T... args)