This code generates a Sudoku puzzle in C++ and then gives the user a chance to solve it in a Windows Console Terminal.
If you want have suggestions or questions about how the code works, I would love to hear from you. The code is basically a stupid backtracking program without any heuristics to speed it up.
There are three basic object types in the system:
- a vector which is an indirect link to a group of nine in the puzzle: sudokuVector.cpp sudokuVector.h
- the puzzle itself which contains the 9x9 array and the vectors: sudokuPuzzle.cpp sudokuPuzzle.h
- the screen which was my second pass at screen handling: conWindow.cpp conWindow.h
There is the main instantiation of a sudokuPuzzle in
sudoku.cpp.
The program runs in a Windows command window and has compiled under VS 2005. The program was made as an example for a student, and I did not have time to clean it up completely. So, the mysterious question of the level of difficulty represents how deep in backtracking is required before giving up. Theoretically, the higher numbers represent a more complicated puzzle
An executable version of the program is on this
blog page.
Jack
Labels: backtracking, C++, sudoku