Im trying to make a sudoku puzzle generator.. my logic is this- make a 9 by 9 array and a single dimensional 9 by 1 array. iterate through 00 to 88 (row wise) of the 1st array with two variables i and j. avery time i increases (and at the beginning)

store the 1D array with numbers from 1 to 9 in order. now choose a number at random from the 1D array. insert it into the i,j th position of the 2d array, if it doesnt violate the sudoku conditions. otherwise , continue. when i insert the number(if it doesnt violate the conditions) i remove that number from the 1 D array.

THe problem is, this program gets stuck. When i tried it for a smaller 3*3 grid, using only 1, 2 and 3 it works.

Note: this is only the first part, where im trying to generate a fully solved grid

Last edited on

If you are just taking a random number and re-choosing when it violates the rules of Sudoku, you'll definitely have a problem because this method will not garuntee a solution.

First try making a solved sudoku grid on your own. You'll probably get stuck on the first try. Your algorithm also gets stuck here too!

Try reading up on sudoku creation algorithms and how to automate this process. I found some people pointing to this document:

http://www.sudokuwiki.org/Sudoku_Creation_and_Grading.pdf

First try making a solved sudoku grid on your own. You'll probably get stuck on the first try. Your algorithm also gets stuck here too!

Try reading up on sudoku creation algorithms and how to automate this process. I found some people pointing to this document:

http://www.sudokuwiki.org/Sudoku_Creation_and_Grading.pdf

I solved the sudoku problem using backtracking...

If you want to also solve sudoku using backtracking, you should try to solve the Eight queens puzzle first as it is easier. Once you figure out how to solve eight queens puzzle, you should have a good idea as to how to solve your sudoku problem

http://www.sendspace.com/file/dshefo

My compiled solution

If you want to also solve sudoku using backtracking, you should try to solve the Eight queens puzzle first as it is easier. Once you figure out how to solve eight queens puzzle, you should have a good idea as to how to solve your sudoku problem

http://www.sendspace.com/file/dshefo

My compiled solution

Last edited on

Topic archived. No new replies allowed.