Add filled() function as a faster alternative to check()
This commit is contained in:
parent
9bc49daf4c
commit
f7d132397f
11
sud.c
11
sud.c
@ -241,3 +241,14 @@ enum check_res check(const struct sudoku *sud)
|
|||||||
/* If we've got this far, all is well. */
|
/* If we've got this far, all is well. */
|
||||||
return SOLVED;
|
return SOLVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool filled(const struct sudoku *sud)
|
||||||
|
{
|
||||||
|
for (unsigned r = 0; r < NDIGITS; ++r) {
|
||||||
|
for (unsigned c = 0; c < NDIGITS; ++c) {
|
||||||
|
if (!sud->cells[r][c].det)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
7
sud.h
7
sud.h
@ -71,6 +71,11 @@ void print(const struct sudoku *sud);
|
|||||||
* Determine whether the sudoku has been solved correctly, contains
|
* Determine whether the sudoku has been solved correctly, contains
|
||||||
* invalid choices or is incomplete.
|
* invalid choices or is incomplete.
|
||||||
*/
|
*/
|
||||||
enum check_res check(const struct sudoku *sud);
|
enum check_res check(const struct sudoku *sud);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether all the sudoku's cells have been determined.
|
||||||
|
*/
|
||||||
|
bool filled(const struct sudoku *sud);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user