Apply rules to segments as well as rows and columns
This commit is contained in:
parent
d74b5410b6
commit
119270c89b
18
solve.c
18
solve.c
@ -120,7 +120,23 @@ int solve(struct sudoku *sud)
|
|||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Apply rules to each segment. */
|
/* Apply rules to each segment. */
|
||||||
|
for (i = 0; i < NDIGITS; ++i) {
|
||||||
|
for (j = 0; j < NDIGITS; ++j) {
|
||||||
|
r = 3 * (i / 3) + j / 3;
|
||||||
|
c = 3 * (i % 3) + j % 3;
|
||||||
|
|
||||||
|
group[j].row = r;
|
||||||
|
group[j].col = c;
|
||||||
|
group[j].state = &sud->cells[r][c];
|
||||||
|
}
|
||||||
|
|
||||||
|
res = apply_rules(sud, &group);
|
||||||
|
if (res == ERROR)
|
||||||
|
return -1;
|
||||||
|
else if (res == MATCH)
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Exit if no matches. */
|
/* Exit if no matches. */
|
||||||
if (!match)
|
if (!match)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user