Compare commits
2 Commits
fcb33c53ba
...
8f387ff781
Author | SHA1 | Date | |
---|---|---|---|
8f387ff781 | |||
370d7516f5 |
26
sudoku.c
26
sudoku.c
@ -88,27 +88,6 @@ void printDumpSudoku() {
|
||||
printf("+-------+-------+-------+\n");
|
||||
}
|
||||
|
||||
void printDumpQuadrat(int q[]) {
|
||||
for (int row = 0; row < 3; row++) {
|
||||
if (row % 3 == 0) {
|
||||
printf("+-------+\n");
|
||||
}
|
||||
for (int col = 0; col < 3; col++) {
|
||||
if (col % 3 == 0) {
|
||||
if (col != 0) {
|
||||
printf(" ");
|
||||
}
|
||||
printf("|");
|
||||
}
|
||||
|
||||
int f = calculateField(row, col);
|
||||
printf(" %d", q[f]);
|
||||
}
|
||||
printf(" |\n");
|
||||
}
|
||||
printf("+-------+\n");
|
||||
}
|
||||
|
||||
// checks if this value is present anywhere in the row
|
||||
bool isInRow(int row, int val) {
|
||||
for (int col = 0; col < 9; col++) {
|
||||
@ -249,7 +228,7 @@ bool isInQuadrat(int q, int val) {
|
||||
void setValue(int q, int f, int val) {
|
||||
sudoku[q][f] = val;
|
||||
printf("=> setting %d in Q %d; F %d\n", val, q, f);
|
||||
printDumpSudoku();
|
||||
//printDumpSudoku();
|
||||
}
|
||||
|
||||
int main() {
|
||||
@ -305,7 +284,6 @@ int main() {
|
||||
}
|
||||
|
||||
// check if only one field is left undefined -> hast to be the one special value
|
||||
int undefinedFound = VALUE_UNDEFINED;
|
||||
for (int f = 0; f < 9; f++) {
|
||||
// keep in mind that sudoku array might have changed since evaluation
|
||||
// -> ignore already set values
|
||||
@ -323,5 +301,5 @@ int main() {
|
||||
}
|
||||
} while (somethingChanged);
|
||||
|
||||
// next step: muss in Feld X sein, weil alle anderen Felder irgendwie anders belegt sein müssen (aber noch nicht sind)
|
||||
printDumpSudoku();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user