int main() { scanf("%d",&test); while(test--) { init(); readSudoku(); solveDLX(0); if(!found) puts("N"); } return 0; }
int main() { fread_unlocked(ibuff, 3000, 1, stdin); getstr(dump); test = atoi(dump); while(test--) { init(); readSudoku(); solveDLX(0); if(test) getstr(dump), *out++ = '\n'; } fwrite_unlocked(obuff, out - obuff, 1, stdout); return 0; }
int main(void) { int puzzle[9][9]; /* array to store the puzzle */ readSudoku(puzzle); /* read in the puzzle */ printf ("%d\n", checkValid(puzzle, 0, 2, 5)); /* place 5 in row 0, column 2 = invalid */ printf ("%d\n", checkValid(puzzle, 0, 2, 8)); /* place 8 in row 0, column 2 = invalid */ printf ("%d\n", checkValid(puzzle, 0, 2, 9)); /* place 9 in row 0, column 2 = invalid */ printf ("%d\n", checkValid(puzzle, 1, 1, 8)); /* place 8 in row 1, column 1 = valid */ printf ("%d\n", checkValid(puzzle, 0, 8, 7)); /* place 7 in row 0, column 8 = valid */ printf ("%d\n", checkValid(puzzle, 8, 0, 6)); /* place 6 in row 8, column 0 = valid */ printf ("%d\n", checkValid(puzzle, 0, 0, 6)); /* place 6 in row 0, column 0 = square not empty */ return 0; }
/** * This program tries to resolve a given Sudoku file. * * @param argc Argument count * @param argv Arguments */ int main(int argc, char** argv) { if (argc != 2) { printf("Usage: <solver> <sudoku file>\n"); exit(EXIT_FAILURE); } else { int ret; // allocate matrix to read into char** sudoku_array = allocate_sudoku(); // read input sudoku file ret = readSudoku(argv[1], sudoku_array); // abort if file is corrupt if (ret != 0) { printf("The read process failed - exiting\n"); exit(EXIT_FAILURE); } // print input sudoku printf("<<INPUT SUDOKU>>\n"); print_sudoku(sudoku_array); printf("-----------------\n"); // solve it ret = solve_sudoku(sudoku_array); // print output sudoku printf("<<OUTPUT SUDOKU>>\n"); print_sudoku(sudoku_array); printf("-----------------\n"); // print if the sudoku could be solved if (ret == 0) printf("The Sodoku was solved\n"); else printf("The Sudoku is irresolvable\n"); // free allocated matrix unallocate_sudoku(sudoku_array); exit(EXIT_SUCCESS); } }