[olug] Programming Question

Obi-Wan obiwan at jedi.com
Thu Mar 6 22:57:50 UTC 2008


> Classic AI method would be to process using recursion assuming that VB 
> supports pass value.  It would be similar to the classic 8 queens 
> problems which is usually used in textbooks for recursion.
> 
> Process goes like this:
> 1. Check to see if the board is full.  If yes print and exit else goto 2.
> 2. Pick an empty square and put a random value in it.
> 3. Check to see if the value is valid for the quadrant and the row.  If 
> yes recurse else pick a new value.  If no value is valid return.

I wrote a sudoku solver in C a while back that does exactly that for
an NxN sudoku puzzle, where N is any perfect square.  On an old P3, it
would solve a 144x144 puzzle in less than one second.  The main program
is shell based.  I put a web-based wrapper around it that only handles
9x9 puzzles.  To generate your test puzzles, just randomly enter a few
values and see if it can solve them.  If so, you've got a valid puzzle.

http://www.jedi.com/obiwan/sudoku/

>> I'm wanting to randomly generate solved boards, then blank out several of
>> the buttons on it. I'm having a problem figuring out the best way to keep
>> track of the possible values when selecting one randomly, assigning it to a
>> position on the board.

How hard can it really be to generate random puzzles by hand on a tiny
4x4 board?

-- 
Ben "Obi-Wan" Hollingsworth                             obiwan at jedi.com
   The stuff of earth competes for the allegiance I owe only to the
     Giver of all good things, so if I stand, let me stand on the
       promise that You will pull me through.  -- Rich Mullins



More information about the OLUG mailing list