Add number of passes to benchmark output
This commit is contained in:
12
solve.c
12
solve.c
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user