Posted: Tue Dec 16, 2008 10:45 pm Post subject: Sudoku Generator
Ive put together a very rudimentary Sudoku grid generator. ive used a sorta 'brute force' approach. it will loop and try to fill the grid. only when the grid is filled will it exit.
based on my method it will sometimes generate a grid quickly, or sometimes it will take a while.
let me know your results: on average how many tries it takes and how long it takes.
ive been able to get a grid in as little as 2 tries in 0.043 CPU seconds
Update* ive been able to generate a grid in 1 try! in 0.028 CPU seconds at a rate of 36 tries per one second
and the most it has taken is 1377 tries in 16.214 CPU seconds
on average im getting about 84 tries per one second
and i would say on average it takes less than 500 tries to generate a grid
please let me know if there are any ways to improve the code or if there are any bugs.
also let me know your ideas on ways to generate a grid and ways to be able to take out numbers from the grid while keeping the grid solvable
Posted: Wed Dec 17, 2008 12:38 am Post subject: Re: Sudoku Generator
You might want to notice that all Sudoku Grids are equivalent. As in all grids can be made from modifying an existing grid (have not proved yet, i am just to believe this not sure why...)
say you have a grid that is 9x9 (being a valid sudoku).
if you swap rows 1,2,3 or 4,5,6 or 7,8,9 (in any fashion) the grid is still valid
if you swap columns 1,2,3 or 4,5,6 or 7,8,9 (in any fashion) the grid is also still valid.
Hopefully you can see where I am going with this and a kind of cool way to generate a Solved Sudoku.
The real hard problem with Sudoku's is Making Solvers (that are efficient) and pulling out numbers so there is only one possible solution.
SushiBuffet
Posted: Wed Dec 17, 2008 9:37 am Post subject: Re: Sudoku Generator
Ultrahex. your idea about swapping rows or columns in that fashion makes perfect sense. i'll try it out . thanks for that
Ultrahex @ Wed Dec 17, 2008 12:38 am wrote:
The real hard problem with Sudoku's is Making Solvers (that are efficient) and pulling out numbers so there is only one possible solution.
This is my greatest problem right now. the easy part of this project is making a grid. the hard part is finding which number to take out.