Sudoku Update and Solve Files

3 views (last 30 days)
Katrina
Katrina on 12 Nov 2015
Answered: Madhu Govindarajan on 12 Nov 2015
I am creating a program that solves Sudoku puzzles and I need help creating two functions. I have a function that creates a "cantbe" matrix that shows what can't go in each square based off what is already in the rows, columns, and subsquares so for example (i,j)=[1 2 3 5 0 7 8 9] means that the number that belongs in that square is 6. First, I need an update function that updates the puzzle for each of the rows and columns with only one zero with the number that belongs. I'm struggling with how to start that function. I assume I'd use some kind of loop to flag and then fill in the puzzle but no idea what exactly to use. Second, for the solve file I need it to as the tile suggests solve the puzzle by calling all the different function files I have so far. So it would read the original puzzle, calls my cantbe function, calls my update function, compares the state of the Sudoku puzzle before the update function is called and after it is called, if they are the same it exits, but if they are different it calls cantbe and update again and finally prints the final state of the puzzle. This I know would use a while loop for when the puzzles before and after are different to call the cantbe and update function, but I'm not 100% sure how to format that.
Any tips for either would be greatly appreciated. Thank you!

Answers (1)

Madhu Govindarajan
Madhu Govindarajan on 12 Nov 2015

Categories

Find more on Sudoku in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!