Quote (Azrad @ Mar 17 2014 11:14pm)
c++ is not my strong suit, but:
why not just make an array of the "allowed values" for a square, then randomly pick one from the array?
That's not what the problem is. When a cell runs out of values to put in (i.e they're all restricted) it just goes onto the next cell
Quote (Minkomonster @ Mar 17 2014 11:22pm)
Does your assignment actually say to use backtracking to solve a sudoku puzzle? I feel for whoever has to test these programs. Solving a 9x9 sudoku board trying every possible combination? Run it, come back a few days later, check the results. No thanks.
In any case, if you are supposed to be implementing recursive backtracking then you are not doing that at all. Fixing this algorithm would require it to be completely rewritten. Can you post the assignment specs, and your entire solution thus far. I don't want to make assumptions off of what you have omitted.
The program has to generate an N size (specified by user) grid filled with numbers, where there are no repeats in any row/column. Have to use backtracking, or recursion, or both, and result has to be random (different result each time you run the prog)
I can pay 1k fg to write me up a program, or more if it's time consuming (pm me the code though)
Also here's an example of what it's doing (4x4 grid, first 2 rows:)
3 1 2 4 - > 3 1 2 4
1 2 3 0 - > 1 2 3 4 <- it fills in this cell with 4 and keeps going. It ends up as
3 1 2 4
1 2 3 4
2 3 4 1
4 4 1 2
This post was edited by Foxic on Mar 17 2014 10:31pm