Implement check() function to verify solver results

This commit is contained in:
2022-11-23 14:36:45 +00:00
parent 4feaedf1a3
commit 39d417f2bc
2 changed files with 70 additions and 1 deletions

10
sud.h
View File

@@ -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