From f84cccc1b510ade19bc445249fef6dadc47a82af Mon Sep 17 00:00:00 2001 From: Imbus Date: Tue, 5 Dec 2023 16:13:57 +0100 Subject: [PATCH] Better comments --- app/src/main/java/sudoku/Solver.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/sudoku/Solver.java b/app/src/main/java/sudoku/Solver.java index 1fea9c7..0d5ca47 100644 --- a/app/src/main/java/sudoku/Solver.java +++ b/app/src/main/java/sudoku/Solver.java @@ -38,6 +38,7 @@ public class Solver implements SudokuSolver { return false; } + // If row is 9, drop down to the next column, if column is 9, we are done if (row == 9) { row = 0; if (++col == 9) { @@ -45,13 +46,17 @@ public class Solver implements SudokuSolver { } } + // If we have a "number" in the current cell + // recursively call solve() on the next cell if (board[row][col] != 0) { return solve(row + 1, col); } + // Check for legal values in the current cell for (int val = 1; val <= 9; ++val) { if (legal(row, col, val)) { board[row][col] = val; + // When we find a legal value, recursively call solve() on the next cell if (solve(row + 1, col)) { return true; }