diff options
author | zedarider <ymherklotz@gmail.com> | 2016-09-08 02:23:30 +0200 |
---|---|---|
committer | zedarider <ymherklotz@gmail.com> | 2016-09-08 02:23:30 +0200 |
commit | 2261ffa0ecbc213eaa8a598b0c9da3925bb64bbf (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src | |
parent | c9d951f0226b568c3c456a5aecc57bd9777a8441 (diff) | |
download | sudoku_solver-2261ffa0ecbc213eaa8a598b0c9da3925bb64bbf.tar.gz sudoku_solver-2261ffa0ecbc213eaa8a598b0c9da3925bb64bbf.zip |
removing files
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 12 | ||||
-rw-r--r-- | src/sudoku_solver.cpp | 107 |
2 files changed, 0 insertions, 119 deletions
diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 23009a7..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "../include/sudoku_solver.hpp" - -using namespace std; - -int main(int argc, char** argv) { - cout << "Sudoku Solver v1.1" << endl << endl; - - SudokuSolver solver; - - solver.printGrid(); - return 0; -} diff --git a/src/sudoku_solver.cpp b/src/sudoku_solver.cpp deleted file mode 100644 index 54888b8..0000000 --- a/src/sudoku_solver.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "../include/sudoku_solver.hpp" - -using namespace std; - -SudokuSolver::SudokuSolver() { - int tmp_int; - grid_file.open("/home/yannherklotz/Github/sudoku_solver/resources/grid.txt", ios::in); - - if(grid_file.is_open()) { - cout << "File successfully opened..." << endl << endl; - } else { - cout << "Failed to open file..." << endl << endl; - exit(EXIT_FAILURE); - } - - while(grid_file >> tmp_int) { - grid.push_back(tmp_int); - } -} - -SudokuSolver::~SudokuSolver() { - -} - -void SudokuSolver::printGrid() { - int count = 0; - int row = 0; - int sep_count = 0; - for(int box : grid) { - cout << box << " "; - ++count; - - if(count % SEPSIZE == 0 && count % GRIDSIZE != 0) { - cout << "| "; - } - - if(count >= GRIDSIZE) { - count = 0; - cout << endl; - ++row; - } - - if(row >= SEPSIZE && sep_count < SEPSIZE-1) { - for(unsigned int i = 0; i < GRIDSIZE + SEPSIZE-1; ++i) { - cout << "- "; - } - cout << endl; - - row = 0; - ++sep_count; - } - } -} - -bool SudokuSolver::checkBox(unsigned int &grid_location, vector<int> &curr_grid) { - int box_location = getBox(grid_location); - - for(unsigned int i = 0; i < curr_grid.size(); ++i) { - if(getBox(i) == box_location && grid_location != i) { - if(curr_grid[grid_location] == curr_grid[i]) { - return false; - } - } - } - - return true; -} - -bool SudokuSolver::checkRow(unsigned int &grid_location, vector<int> &curr_grid) { - int row = grid_location / GRIDSIZE; - - for(unsigned int i = 0; i < curr_grid.size(); ++i) { - int tmp_row = i / GRIDSIZE; - if(row == tmp_row && grid_location != i) { - if(curr_grid[grid_location] == curr_grid[i]) { - return false; - } - } - } - - return true; -} - -bool SudokuSolver::checkColumn(unsigned int &grid_location, vector<int> &curr_grid) { - int column = grid_location % GRIDSIZE; - - for(unsigned int i = 0; i < curr_grid.size(); ++i) { - int tmp_col = i % GRIDSIZE; - if(column == tmp_col && grid_location != i) { - if(curr_grid[grid_location] == curr_grid[i]) { - return false; - } - } - } - - return true; -} - -int SudokuSolver::getBox(unsigned int grid_location) { - int column = grid_location % GRIDSIZE; - - int box_row = grid_location / (GRIDSIZE * SEPSIZE); - int box_column = column / SEPSIZE; - - int box_location = box_row * 3 + box_column; - return box_location; -} |