Add number of passes to benchmark output

This commit is contained in:
2022-11-23 15:46:21 +00:00
parent 07c1fc7a0f
commit d74b5410b6
3 changed files with 20 additions and 12 deletions

12
solve.c
View File

@@ -80,14 +80,14 @@ static enum apply_res apply_rules(struct sudoku *sud, cellgroup *group)
return matched ? MATCH : NO_MATCH;
}
bool solve(struct sudoku *sud)
int solve(struct sudoku *sud)
{
cellgroup group = { 0 };
unsigned r, c;
unsigned r, c, i, j, n;
bool match;
enum apply_res res;
for (unsigned i = 0;; ++i) {
for (n = 0;; ++n) {
match = false;
/* Apply rules to each row. */
@@ -100,7 +100,7 @@ bool solve(struct sudoku *sud)
res = apply_rules(sud, &group);
if (res == ERROR)
return false;
return -1;
else if (res == MATCH)
match = true;
}
@@ -115,7 +115,7 @@ bool solve(struct sudoku *sud)
res = apply_rules(sud, &group);
if (res == ERROR)
return false;
return -1;
else if (res == MATCH)
match = true;
}
@@ -124,6 +124,6 @@ bool solve(struct sudoku *sud)
/* Exit if no matches. */
if (!match)
return true;
return n;
}
}