How to generate the Sudoku puzzle from solved solution?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hi everybody,
(I searched entire forum before create this new thread!)
I'm currently writing a Sudoku game for me now. I have already generated the Sudoku solutions from a solved solution (by using shuffle groups or lines) and from the empty Sudoku board (by backtracking algorithm). Now I'm confusing when I want to generate the Sudoku puzzle from the solved solutions - removing some values from squares flows three levels: Hard, Medium and Easy.
Are you advanced in the Sudoku game? Let me know your experiences in my gratitude!
Something you might not learn without a lot of hacking is how to strategically remove numbers so that the puzzle is still solvable and still has only one solution. I don't know how to do that, but in my opinion, that sounds like a lot more work than generating the solved puzzle (at least comparable to the difficulty level you hope to achieve.) You probably need a strong algorithm. I doubt all of the free sudoku projects take that into account; some probably give you an unsolvable puzzle without knowing it. Then again, this is all just ignorant speculation.
Kevin Barry
You probably need a strong algorithm. I doubt all of the free sudoku projects take that into account; some probably give you an unsolvable puzzle without knowing it.
A brief review of the google results suggests that some of the projects address these issues more carefully than others. One of the most promising ones (judging by its blurb) was tempting enough that I actually tried running it, and it blew up with a setjmp error, whatever that is.
A brief review of the google results suggests that some of the projects address these issues more carefully than others. One of the most promising ones (judging by its blurb) was tempting enough that I actually tried running it, and it blew up with a setjmp error, whatever that is.
setjmp sets a reference point on the stack for use later, then a call to longjmp unwinds the stack back to that point. I can't think of any good reason to have that in Sudoku. Really the only reason I could see using it is implementation of an exception system.
Kevin Barry
well, the obvious method is staring you in the face
you've already done it!
get a solution,
1. remove some numbers,
2. run it through your solver
3. repeat
maybe make some metrics in your solver on how many steps the solution takes?
or depth of backtrack etc.
While probably effective, that's a somewhat unintelligible way to do it. This would be a great opportunity to practice algorithm design and problem analysis.
Kevin Barry
(My English is very bad)
Thanks everyone for your replies although I'm still not found out what I need. I'm currently reading some open source code of Sudoku game. I hope that I can find out solution for my problems. I've generated my puzzles but there are a few solutions for each of them, but what I need is a puzzle that there is only one solution. Thanks everyone again, I'm waiting for your help!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.