LinuxQuestions.org
Social Bookmarking all things Linux and Open Source
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

Tags used in this thread
Popular LQ Tags , , , , , , , ,

Reply
 
Thread Tools
Old 02-26-2009, 09:29 PM   #1
pumpkin
LQ Newbie
 
Registered: Feb 2009
Posts: 7
Thanked: 0
How to generate the Sudoku puzzle from solved solution?


[Log in to get rid of this advertisement]
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!
pumpkin is offline  
Tag This Post , , , , , , , ,
Reply With Quote
Old 02-26-2009, 10:08 PM   #2
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: Slackware 12.1
Posts: 449
Thanked: 51
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.
wje_lq is offline     Reply With Quote
Thanked by:
Old 02-27-2009, 01:58 AM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: Slackware 11.0, Slackware 12.1, slamd64 12.2, Ubuntu Server 8.04, Kubuntu 9.04
Posts: 2,081
Thanked: 39
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 01:59 AM..
ta0kira is offline     Reply With Quote
Thanked by:
Old 02-27-2009, 05:40 AM   #4
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: Slackware 12.1
Posts: 449
Thanked: 51
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.
wje_lq is offline     Reply With Quote
Old 02-27-2009, 09:38 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Puppy
Posts: 2,712
Thanked: 21
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.
bigearsbilly is offline     Reply With Quote
Thanked by:
Old 02-28-2009, 05:04 AM   #6
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: Slackware 11.0, Slackware 12.1, slamd64 12.2, Ubuntu Server 8.04, Kubuntu 9.04
Posts: 2,081
Thanked: 39
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
ta0kira is offline     Reply With Quote
Old 02-28-2009, 05:07 AM   #7
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: Slackware 11.0, Slackware 12.1, slamd64 12.2, Ubuntu Server 8.04, Kubuntu 9.04
Posts: 2,081
Thanked: 39
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
ta0kira is offline     Reply With Quote
Old 02-28-2009, 05:14 AM   #8
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: Slackware 11.0, Slackware 12.1, slamd64 12.2, Ubuntu Server 8.04, Kubuntu 9.04
Posts: 2,081
Thanked: 39
(accidentally posted twice because of database crash)
ta0kira is offline     Reply With Quote
Old 03-01-2009, 06:23 AM   #9
pumpkin
LQ Newbie
 
Registered: Feb 2009
Posts: 7
Thanked: 0

Original Poster
(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 06:28 AM..
pumpkin is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 08:41 AM
LXer: Use Firefox XForms to create your own Sudoku LXer Syndicated Linux News 0 03-01-2007 01:31 PM
Proposed solution for "status" (aka "problem solved") indicator demerson3 LQ Suggestions & Feedback 12 04-08-2006 03:15 PM
Let us develop a C program to resolve the Sudoku square ewt3y Programming 21 08-30-2005 01:09 PM
'PEAR.php' (include_path=''.:/usr/local/lib/php'') SOLVED SOLVED adengua Linux - Software 0 04-02-2004 04:34 AM


All times are GMT -5. The time now is 02:18 AM.

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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration