This is a simple yet efficient sudoku solver and generator with many updates to come. It solves sudokus using human logic and is capable of listing the steps needed to solve the given sudoku. It can also generate sudokus of varying difficulty in reasonable time (0 sec -5 sec) for most difficulties.

What sets it apart from other generators and solvers you find around the internet is that it guarantees uniquely solvable sudokus in reasonable times with steps used to solve it. It is designed to be easily incorporated in bigger projects and used as it is. Most code around the internet is either to specific and not easily incorporated in other projects, not efficient or not humanly readable or understandable and doesn't provide steps. Other than that support and updates will be available unlike other sources which makes it worth for long term use. The code saves you over 1000 lines of code which has been tested extensively and works out of the box.

Many updates are to come to extend the solver logic and make speed improvements.

Example usage:

```
Sudoku su;//Declaration
su.reset();//Resets the data in the sudoku
int data[]={0,6,0,8,7,0,1,0,0,2,0,0,0,0,6,7,9,8,8,0,7,2,0,0,4,0,0,9,1,8,3,2,0,0,0,6,0,4,0,0,0,7,8,0,9,0,0,0,0,0,0,0,0,3,0,8,0,0,0,2,0,0,4,0,0,3,7,6,0,9,0,0,0,2,9,4,3,0,6,8,0};
su.set_matrix(data); //Sets a sudoku to the data provided row by row where 0 denotes an empty space
//This is the faster method
string data="060870100200006798807200400918320006040007809000000003080002004003760900029430680";
su.set_matrix(data);//Sets a sudoku to the data provided row by row where 1-9 are valid values 0 and . represent empty cells and everything else gest skipped.
//It's the preffered method as it's the most flexible
su.get_possble(5,3);//Returns an integer whose binary representation represents the possible candidates in that cell (row,column)
//eg. 12 in base 2 is 1100 so the possible candidates are 3 and 4 (1 being the rightmost and 9 being the leftmost bit)
su.update_possible();//Updates the possible candidates for each cell in case that some changes are made
su.solve(true,3);//Solves the current matrix. The 1st argument is a bool that determines wether to save the steps that were made , the 2nd argument determines the difficulty of the matrix 1-3
//The function returns a bool true meaning the sudoku was solved, false meaning it wasn't
su.generate(2,40);//A function that generates new sudokus from solved ones. The 1st argument is the difficulty of the supposed matrix the 2nd one is the number of emty cells that are to be made
//If success it returs true otherwise false
//Maximum depth for now is 50 since any more takes too long for a matrix to generate
su.generate_simple();//Sets the matrix to a simple solved sudoku, usefull for generating new sudokus if you don't have your own solved ones
su.generate_until_found(1,45,20000);//This function attempts to generate a sudoku from the provided matrix. The 1st arguments is the wanted difficulty, the 2nd is the wanted depth and the 3rd one is the number of attempts
su.generate_until_found_simple(2,43,25000)//Same as the previous function but uses a simple generated sudoku
su.shuffle();//Shuffles the sudoku matrix in a valid manner so additional sudokus can be produced from existing ones
su.print_matrix();//Prints the matrix in a command line fashion
su.print_matrix_with_possible();//Prints the sudoku with the possibilities for every cell in a command line fashion
su.return_matrix_as_string();//Returns the matrix in form of a string 1-9 being cells with values and 0 being cells that are empty
su.return_steps();//Returns a vector
``` that contains the steps in chronological order with location and step
//The generating and solving functions have default values that are used if you don't provide your own
//There are lots of others internal functions that can be used but are not mentioned
//Future updates will contain speed and difficulty improvements

Developer LicensePurchased on Jan 14, 20135 years agoDeveloper LicensePurchased on Jan 14, 20135 years ago