Add load() for loading sudokus from text
This commit is contained in:
12
sud.c
12
sud.c
@@ -35,6 +35,18 @@ static void initposs(struct sudoku *sud)
|
||||
}
|
||||
}
|
||||
|
||||
bool load(struct sudoku *sud, const char *ptr)
|
||||
{
|
||||
initposs(sud);
|
||||
for (unsigned i = 0; i < NCELLS; ++i) {
|
||||
if (ptr[i] == '0')
|
||||
continue;
|
||||
if (update(sud, i / NDIGITS, i % NDIGITS, ptr[i] - '1') != OK)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void clear(struct sudoku *sud, unsigned r, unsigned c)
|
||||
{
|
||||
unsigned tr, tc, val;
|
||||
|
||||
Reference in New Issue
Block a user