필터 지우기
필터 지우기

Sudoku Update and Solve Files

조회 수: 5 (최근 30일)
Katrina
Katrina 2015년 11월 12일
답변: Madhu Govindarajan 2015년 11월 12일
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!

답변 (1개)

Madhu Govindarajan
Madhu Govindarajan 2015년 11월 12일

카테고리

Help CenterFile Exchange에서 Sudoku에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by