Implement check() function to verify solver results
This commit is contained in:
10
sud.h
10
sud.h
@@ -22,7 +22,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#define SEGLEN 3
|
||||
#define NDIGITS 9
|
||||
#define NDIGITS (SEGLEN * SEGLEN)
|
||||
|
||||
struct cellstate {
|
||||
bool det;
|
||||
@@ -38,6 +38,8 @@ struct sudoku {
|
||||
|
||||
enum update_res { NOT_ALLOWED, ALREADY_DET, OK };
|
||||
|
||||
enum check_res { INCOMPLETE, INCORRECT, SOLVED };
|
||||
|
||||
/**
|
||||
* Populate the sudoku with some random values.
|
||||
*/
|
||||
@@ -57,4 +59,10 @@ update(struct sudoku *sud, unsigned r, unsigned c, unsigned val);
|
||||
*/
|
||||
void print(const struct sudoku *sud);
|
||||
|
||||
/**
|
||||
* Determine whether the sudoku has been solved correctly, contains
|
||||
* invalid choices or is incomplete.
|
||||
*/
|
||||
enum check_res check(const struct sudoku *sud);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user