From 8f93d832318dd960842940b3e688332124484f51 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 6 Jun 2012 18:25:47 +0000 Subject: Added unique solution step solver. --- src/solverwindow.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/solverwindow.cc') diff --git a/src/solverwindow.cc b/src/solverwindow.cc index 9bda3d5..06de5fb 100644 --- a/src/solverwindow.cc +++ b/src/solverwindow.cc @@ -150,4 +150,20 @@ void SolverWindow::clear() void SolverWindow::step() { + int nbSolutions = 0; + Sudoku sudoku; + solverwindow_sudokuwidget->get_values(sudoku); + + Sudoku solution; + for (int row = 0; row < 9; row++) { + for (int column = 0; column < 9; column++) { + int i = sudoku.solve_step(row, column); + if ((i > 0) && (sudoku.value(row, column) == 0)) { + nbSolutions++; + } + solution.value(row, column) = i; + } + } + solverwindow_sudokuwidget->set_values(solution); + qDebug() << nbSolutions << " cells solved"; } \ No newline at end of file -- cgit v1.2.3