LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-26-2009, 08:29 PM   #1
pumpkin
LQ Newbie
 
Registered: Feb 2009
Posts: 10

Rep: Reputation: 1
How to generate the Sudoku puzzle from solved solution?


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!

Your helps are valuable presents for me!

Thanks and best regards!
 
Old 02-26-2009, 09:08 PM   #2
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 809

Rep: Reputation: 178Reputation: 178
You can learn much from studying the source code of others. You'll find sudoku generators of varying quality and in various languages here.

Hope this helps.
 
Old 02-27-2009, 12:58 AM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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

Last edited by ta0kira; 02-27-2009 at 12:59 AM.
 
Old 02-27-2009, 04:40 AM   #4
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 809

Rep: Reputation: 178Reputation: 178
Quote:
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.
 
Old 02-27-2009, 08:38 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,290

Rep: Reputation: 174Reputation: 174
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.
 
Old 02-28-2009, 04:04 AM   #6
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by wje_lq View Post
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
 
Old 02-28-2009, 04:07 AM   #7
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by bigearsbilly View Post
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
 
Old 02-28-2009, 04:14 AM   #8
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
(accidentally posted twice because of database crash)
 
Old 03-01-2009, 05:23 AM   #9
pumpkin
LQ Newbie
 
Registered: Feb 2009
Posts: 10

Original Poster
Rep: Reputation: 1
(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!

Kind regards and greetings to LQ's members ^^

Last edited by pumpkin; 03-01-2009 at 05:28 AM.
 
  


Reply

Tags
from, generate, how, solution


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Create a Sudoku Rich Client game with Eclipse LXer Syndicated Linux News 0 02-02-2008 07:41 AM
LXer: Use Firefox XForms to create your own Sudoku LXer Syndicated Linux News 0 03-01-2007 12:31 PM
Proposed solution for "status" (aka "problem solved") indicator demerson3 LQ Suggestions & Feedback 12 04-08-2006 02:15 PM
Let us develop a C program to resolve the Sudoku square ewt3y Programming 21 08-30-2005 12:09 PM
'PEAR.php' (include_path=''.:/usr/local/lib/php'') SOLVED SOLVED adengua Linux - Software 0 04-02-2004 03:34 AM


All times are GMT -5. The time now is 05:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration