From c22536813e9b7b8c6cabaa97660f1876b0df1832 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 5 Aug 2012 14:43:58 +0000 Subject: Added comments. --- src/sudoku.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/sudoku.cc b/src/sudoku.cc index d55a43b..9fcb865 100644 --- a/src/sudoku.cc +++ b/src/sudoku.cc @@ -1,4 +1,6 @@ +// #include + #include "sudoku.h" Sudoku::Sudoku() @@ -81,6 +83,7 @@ void Sudoku::reset_cell(int pos_row, int pos_column) // eliminate subgrid int grid_row = pos_row - (pos_row % 3); int grid_column = pos_column - (pos_column % 3); + for (int row = grid_row; row < grid_row + 3; row++) { for (int column = grid_column; column < grid_column + 3; column ++) { if ((column != pos_column) && (row != pos_row)) { @@ -127,6 +130,7 @@ int Sudoku::solve_coverage() if (covered == 8) { // value is only possible for a single cell solution.set_value(row, available_column, v); + // qDebug() << "(" << row << "," << available_column << ") row covered, value " << v; } } @@ -147,6 +151,7 @@ int Sudoku::solve_coverage() if (covered == 8) { // value is only possible for a single cell solution.set_value(available_row, column, v); + // qDebug() << "(" << available_row << "," << column << ") column covered, value " << v; } } @@ -156,7 +161,7 @@ int Sudoku::solve_coverage() const int sg_row = (subgrid / 3) * 3; const int sg_column = (subgrid % 3) * 3; - // transle linear subgrid positions to row, col coordinate + // translate linear subgrid positions to row, col coordinate for (int subgrid_pos = 0; subgrid_pos < 9; subgrid_pos++) { int sg_rowidx = sg_row + subgrid_pos / 3; int sg_colidx = sg_column + subgrid_pos % 3; @@ -172,9 +177,10 @@ int Sudoku::solve_coverage() if (covered == 8) { // value is only possible for a single cell - int sg_rowidx = sg_row + available_pos / 3; - int sg_colidx = sg_column + available_pos % 3; - solution.set_value(sg_rowidx, sg_colidx, v); + int av_rowidx = sg_row + available_pos / 3; + int av_colidx = sg_column + available_pos % 3; + solution.set_value(av_rowidx, av_colidx, v); + // qDebug() << "(" << av_rowidx << "," << av_colidx << ") subgrid covered, value " << v; } } } -- cgit v1.2.3