So I wanted to solve the SUDOKU I just recognized from the image I fed in MATLAB and I tried various logic but nothing worked better than "Backtracking". You can find a great explanation of this on YouTube or http://www.geeksforgeeks.org/backtracking-set-3-n-queen-problem/ .
Basically, a function is made to recur and return values as true or false if the consistency is maintained or not respectively.
Unlike N-Queen problem where you can output simultaneously, you might find need a global variable that stores the ANSWER matrix of SUDOKU if no empty boxes are possible; or else returning values and stepping out of recurring functions might result in losing of the solved matrix.
I could solve a 9x9 SUDOKU in 3 seconds. My program needs optimization.
Will keep posted on program optimization and better image processing techniques because the current one carries several cons.
Basically, a function is made to recur and return values as true or false if the consistency is maintained or not respectively.
Unlike N-Queen problem where you can output simultaneously, you might find need a global variable that stores the ANSWER matrix of SUDOKU if no empty boxes are possible; or else returning values and stepping out of recurring functions might result in losing of the solved matrix.
I could solve a 9x9 SUDOKU in 3 seconds. My program needs optimization.
Will keep posted on program optimization and better image processing techniques because the current one carries several cons.
No comments:
Post a Comment