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

namespace  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

137 {
138 const int V = 9;
140 std::array <int, V> {5, 3, 0, 0, 7, 0, 0, 0, 0},
141 std::array <int, V> {6, 0, 0, 1, 9, 5, 0, 0, 0},
142 std::array <int, V> {0, 9, 8, 0, 0, 0, 0, 6, 0},
143 std::array <int, V> {8, 0, 0, 0, 6, 0, 0, 0, 3},
144 std::array <int, V> {4, 0, 0, 8, 0, 3, 0, 0, 1},
145 std::array <int, V> {7, 0, 0, 0, 2, 0, 0, 0, 6},
146 std::array <int, V> {0, 6, 0, 0, 0, 0, 2, 8, 0},
147 std::array <int, V> {0, 0, 0, 4, 1, 9, 0, 0, 5},
148 std::array <int, V> {0, 0, 0, 0, 8, 0, 0, 7, 9}
149 };
150
151 backtracking::printMat<V>(mat, mat, 9);
152 std::cout << "Solution " << std::endl;
153 std::array <std::array <int, V>, V> starting_mat = mat;
154 backtracking::solveSudoku<V>(mat, starting_mat, 0, 0);
155
156 return 0;
157}
T endl(T... args)
Here is the call graph for this function: