Add load() for loading sudokus from text

This commit is contained in:
2022-11-23 22:17:38 +00:00
parent 0ca01985cd
commit 9bc49daf4c
2 changed files with 19 additions and 0 deletions

7
sud.h
View File

@@ -23,6 +23,7 @@
#define SEGLEN 3
#define NDIGITS (SEGLEN * SEGLEN)
#define NCELLS (NDIGITS * NDIGITS)
struct cellstate {
bool det;
@@ -40,6 +41,12 @@ enum update_res { NOT_ALLOWED, ALREADY_DET, OK };
enum check_res { INCOMPLETE, INCORRECT, SOLVED };
/**
* Read `NCELLS` values from the given pointer and load them into the
* sudoku.
*/
bool load(struct sudoku *sud, const char *ptr);
/**
* Populate the sudoku with some random values. The proportion of
* cells that are filled will be approximately `fill_prop`.