
May 18th, 2008, 03:44 PM
#1
Sudoku Generator
So I decided that I wanted to make a Sudoku creator and solver for fun. My plan is to fill a sudoku board with random, however, compatible answers using brutefruce. I simply check random numbers against the two prerequisite rules for a legitimate Sudoku: a given cell cannot contain the same number as any cell in the same vertical or horizontal axises as itself and a given cell cannot contain the same number as those contained by cells in its respective 3x3.
Later I hope to enumerate the strategies that humans use to solve Sudoku puzzles and apply these hueristics to a solver. Next, I want to remove numbers one by one from the random, bruteforcecreated solved sudoku puzzle. I could then verify that the resulting sequence of numbers is solvable using my sudoku puzzle solver. If it is not, a different random number can be removed.
Currently I am curious how to implement the second rule of sudoku above. I currently have a 9x9 multidimensional array, and I want to verify that a given cell in this array is not equal to any of the other cells in its 3x3 square. I was thinking of creating a set of rules for each coordinate using the modulus operator. If I divided by 3, I could use the remainder of each cell in some sort of algorithm. Using modulus would ensure that each number is located in the same place within its respective 3x3 square and thus has the same value. Depending on the value, a certain set of rules would determine which indices to compare a given square to.
I am not too sure how to proceed from here. Any suggestions. My main issue is that I cannot say
if (Board [x%3] != so and so) because each of these indices have values. I would be comparing the values inside the indices with one another, which is not what I want to do. I hope this makes some sense. I'll post my code if this is as confusing as it sounds to me.

May 18th, 2008, 05:42 PM
#2
Re: Sudoku Generator
Hello Zoner7!
I take it that you do not have a working sudoku generator and a solver.
if so, I strongly recommend that you read up on backtracking, Alogrithm X, or dancing links because it will save you time (and headache!)
good luck!

May 18th, 2008, 07:48 PM
#3
Re: Sudoku Generator
Thank you for suggestions. I've already started reading up on the topics. heh... well, now that I've basically finished the first part of my Sudoku creator, I realize that this other guy's method looks a lot simpler (however in a more complex way) than my own.
Right now I'm struggling to turn things into functions so that I can understand my own code. I think I'll start posting snippits of code to ask for help. My main issue is that I haven't written anything in 6 months, and the only period over which I did do anything was during a 2 week long span over Christmas vacation, so I've forgotten a lot of the simpler rules. I'm just not sure if a lot of what I am doing is legal.

May 19th, 2008, 05:40 PM
#4
Re: Sudoku Generator
Originally Posted by zoner7
Right now I'm struggling to turn things into functions so that I can understand my own code. I think I'll start posting snippits of code to ask for help. My main issue is that I haven't written anything in 6 months, and the only period over which I did do anything was during a 2 week long span over Christmas vacation, so I've forgotten a lot of the simpler rules. I'm just not sure if a lot of what I am doing is legal.
It happens!!! :)
One idea of confirming legalized code is to write small code segments with doubted components, compile them and see the results. This will prevent you to face lot of errors when you finish a complete module or program.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
OnDemand Webinars (sponsored)
