Posts

Showing posts from March 30, 2019

Simple recursive Sudoku solver

Image
17 3 $begingroup$ My Sudoku solver is fast enough and good with small data (4*4 and 9*9 Sudoku). But with a 16*16 board it takes too long and doesn't solve 25*25 Sudoku at all. How can I improve my program in order to solve giant Sudoku faster? I use backtracking and recursion. It should work with any size Sudoku by changing only the define of SIZE , so I can't make any specific bit fields or structs that only work for 9*9 , for example. #include <stdio.h> #include <math.h> #define SIZE 16 #define EMPTY 0 int SQRT = sqrt(SIZE); int IsValid (int sudoku[SIZE][SIZE], int row, int col, int number); int Solve(int sudoku[SIZE][SIZE], int row, int col); int main() { int sudoku[SIZE][SIZE] = { {0,1,2,0,0,4,0,0,0,0,5,0,0,0,0,0}, {0,0,0,0,0,2,0,0,0,0,0,0,0,14,0,0}, {0,0,0,0,0,0,0,0,0...