Sudoku Generator

Programs which generate, solve, and analyze Sudoku puzzles

Sudoku Generator

Postby Xenos » Mon Jan 02, 2006 12:46 pm

Hi everybody,

for a school project I am working on a sudoku generator. In my mind I had a step plan for writing this program:

- Program solver functionality ( Finished )
- Program a function that can create random sudoku solutions ( Problem )
- Program a function that takes this random solution, removes random numbers and checks if the sudoku is still solveable. ( Not started yet )

I have tried to finish that second step, just by looping through a 81 number integer until it forms a sudoku solution, but this takes way to long.

Is there an easier way? I want a sudoku to appear within seconds, is this possible?

Please help me out,

David
Xenos
 
Posts: 3
Joined: 02 January 2006

Postby Xenos » Tue Jan 03, 2006 12:23 pm

Anyone? I mean... surely, I am not the first person who asks this? Just let me make more clear how I have been trying to create a random sudoku solution:

Take 9 9-number integers. ( like 1 81-number integer, but that is too big for a normal int ). I have written a function that acts as if there 9 9-number itegers were one 81-number integer. It can increase this integer with one every time I ask it to. The thing I do is this:

- Create a random 81-number integer
- Increase this integer with 1 if it does not for a sudoku solution yet

I am not gonna tell you how it checks if it is a sudoku solution... seeing as it does not matter. The point is, just the looping through a 81 number solution is too much for the computer....and I have a fairly modern pentium 4 machine....

Everywhere on forums I see people write: If you have a solver, it's not hard to make a generator out of it. Just brute-force a solution and remove numbers. As long as the solver can solve it, it's a sudoku. But I am starting to believe that this brute-forcing idea is too time absorbent and people don't know what they are talking about? Or am I doing something wrong?

And if I am right, and this bruteforcing is just not the way to do it: What is the way to do it?

Please reply, anything:D

David
Xenos
 
Posts: 3
Joined: 02 January 2006

Postby Animator » Tue Jan 03, 2006 12:26 pm

First try to make a puzzle by hand. If you succeed in doing that then you can start working on a program.

A page which has a tutorial on how to create a puzzle: http://www.pro.or.jp/~fuji/sudoku/makesudoku/sudoku01.html.en
Animator
 
Posts: 469
Joined: 08 April 2005

Postby Xenos » Tue Jan 03, 2006 5:48 pm

Thanks for your reply animator, but the thing is. I think writing a generator using logic like that, will take much more time then I planned for that part. Isn't there a quick and efficient way to brute force a solution? Once you have a solution, it's not so hard to remove numbers and use the solver to check if it's still solvable....
Xenos
 
Posts: 3
Joined: 02 January 2006

Postby tso » Tue Jan 03, 2006 11:55 pm

You might want to take a look at The Sudoku Programmers' Forum.
tso
 
Posts: 798
Joined: 22 June 2005


Return to Software

cron