// Procedure: solve_sudoku // Solve the given sudoku instance. int solve_sudoku(int sudoku[9][9]) { // BEG TODO. int i, j; if(cell_check(&i, &j, sudoku) == 1) //check if the sudoku board is all filled out return 1; else { for(int val = 1; val <= 9; val++) { if(is_val_valid(val, i, j, sudoku) == 1) //if the board is not full, check if a value can be input into the cell. { sudoku[i][j] = val; //if valid, insert the value into the cell. if(solve_sudoku(sudoku) == 1) //solve the board with this value in place of the cell. { return 1; } sudoku[i][j] = 0; //if not solvable with this value in the cell, try next value++. } } } return 0; // END TODO. }
int main(int argc, char ** argv) { (void)argc; (void)argv; unsigned long rc = cell_check(CELL_CHECK_MSG_FAIL, CELL_CHECK_TEST_ALL); printf("cell_check() rc:%lu\n", rc); return 0; }