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, const std::array< std::array< int, V >, V > &starting_mat, int n)
template<size_t V>
bool | backtracking::solveSudoku (std::array< std::array< int, V >, V > &mat, const std::array< std::array< int, V >, V > &starting_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

{
const int V = 9;
std::array <std::array <int, V>, V> mat = {
std::array <int, V> {5, 3, 0, 0, 7, 0, 0, 0, 0},
std::array <int, V> {6, 0, 0, 1, 9, 5, 0, 0, 0},
std::array <int, V> {0, 9, 8, 0, 0, 0, 0, 6, 0},
std::array <int, V> {8, 0, 0, 0, 6, 0, 0, 0, 3},
std::array <int, V> {4, 0, 0, 8, 0, 3, 0, 0, 1},
std::array <int, V> {7, 0, 0, 0, 2, 0, 0, 0, 6},
std::array <int, V> {0, 6, 0, 0, 0, 0, 2, 8, 0},
std::array <int, V> {0, 0, 0, 4, 1, 9, 0, 0, 5},
std::array <int, V> {0, 0, 0, 0, 8, 0, 0, 7, 9}
};
backtracking::printMat<V>(mat, mat, 9);
std::cout << "Solution " << std::endl;
std::array <std::array <int, V>, V> starting_mat = mat;
backtracking::solveSudoku<V>(mat, starting_mat, 0, 0);
return 0;
}
std::array
std::cout
std::endl
T endl(T... args)
Here is the call graph for this function: