>>7
No my code worked on a iterative check whether the sudoku produced was correct. If it was false it would attempt to replace elements marked as unstable. If that failed it would go back to the start and remake the sudoku.
So I guess three times without modification. It generates a sudoku and then, it will make one with unfilled spaces from the already existing one. I'm not a programmer so I don't know the best way to approach creating a sudoku without the problems of incorrect boards being produced.
I have tried this before about three years ago and found it moderately difficult- namely because I was still using java and was a gigantic faggot. If you don't want to go into some advanced numerical analysis the easiest way perhaps would be to implement a deterministic solver that never guesses, and if it can't solve the puzzle without guessing (i.e.: one solution only) terminates. Then to generate a sudoku start adding random numbers in random places and keep adding more until the solver returns a single solution.
Name:
Anonymous2009-03-08 20:22
Once generated, how do you go about hiding the numbers such that it will have a unique solution?
>>15
Start off with a blank array and add a couple of random elements into it from a completed sudoku. Now you need to check whether those elements give clues to one another or not. If they do, depending on difficulty you remove them and replace or you add more that would give clues. In total mine generally shows about 18 numbers, but can show as many as 30.
Name:
Anonymous2009-03-08 20:54
>>16
Too bloated. Doesn't actually produce a sudoku on it's first attempt.
I've rand it 5000 times, and the result was always a VALID SUDOKU GRID.
Average performance: 0.00 real 0.00 user 0.00 sys
Median performance: 0.00 real 0.00 user 0.00 sys
>>31
The only way to produce a perfect sudoku without going through numerous attempts is to solve a board with pre-placed numbers all around the board.
The method that he uses is very similar to mine. If the puzzle is unsolvable it will replace it with a new version of it. At least that's what I think, then again I can't really read Python(I'm not a programmer, and python is hard to understand).