• 07-31-2006
Ideswa
I am trying to make a Sudoku-solver, so far I have made the class 'board' and a way to enter which field you want to fill with a number (the beginning numbers). How should I store the numbers? With arrays?
• 07-31-2006
ElastoManiac
Use [3][3][3] array for storing numbers, In order to solve it think for yourself, do you know the rules?
• 07-31-2006
Ideswa
yes, with counting the total value of the numbers in rows, columns and squares.

Edit: [3][3][3] is wrong, because you have 27 fields in that array and you need: 9 * 9 fields. [9][9] seems to be the right solution for me.
• 07-31-2006
anon
I wrote a (lousy) logical solver recently. I used a Cell class, and a Sudoku (board) class which had 3 copies of a [81] array of Cells: one sorted by rows, one by column and one by regions. Each cell object also had 2 pointers (or array indices) to the corresponding Cells in the other 2 arrays, so that by modifying a cell in respect to a row, I could modify the corresponding cells in column and region. Having three copies of the board may not be too efficient, but it sure made scanning each row, column and region a lot easier (and the program works reasonably fast).

On second thought it would have been even better to use one [3][81] array for the three copies of the board (I basically had a lot of copied-n-pasted code), but I was almost finished when it occurred to me.
• 07-31-2006
twomers
Do it the VERY long way! the one that would have ~9^40 possibilities!!!

I've been thinking about making one for ages, but I haven't gotten around to it. I'll prob do it next year in college when I should be doing something different.

However, I'd recommend that you attempt to make the solver function the same way you attempt to solve the puzzle yourself. If you can solve a puzzle, do one again, but write down the methodology you employ to solve it, and the pseudocode a rough function. There should be a number of functions you could use in your program. As I said, try some puzzles, write down how you solve them, and then try to write the program.

EDIT - maybe he meant a [9][9][9] array ...
• 08-01-2006
cyph1e
Here's an article about it: http://www.osix.net/modules/article/?id=792.
• 08-01-2006
Ideswa
Thanks for the tips!