Sudoku Solver

First off i dont want the entire answer. I would like to learn from this. I just started to program in C++ and I have to program a sudoku solver. First off I have this typed so far.

typedef SetOfSmallInts Puzzle[9][9];
int main()
{
Puzzle p;
Puzzle q;
cout << "Enter sudoku problem:" << "\n";
readPuzzle(p);
printPuzzle(p);
showPuzzle(p);
copyPuzzle(q, p); //need to copy p into q
printPuzzle(
}

void readPuzzle(Puzzle p)
{
char c;
for(i = 0; i < 9; i++)
{
for(j = 0; j < 9; j++)
{
cin >> c;
if (p[i][j]=='-')
{
p[i][j] = rangeSet(1,9);
}
else
{
p[i][j] = singletonSet(c-'0')
}
}
}
}

Any thoughts of how I should procedd with this. Using sets like union, intersection, and difference. For example, taht singletonSet up there means that that square is good. It only has 1 value in it. But a hyphen means that that square is unknown and that rangeSet can have the values 1 through 9 in it. Thanks.
I would make every element of the 9x9 matrix a std::set<> or std::bitset<9>. In either case the set/bitset would represent the values that could possibly be placed in the cell. A cell with only one value in the set is solved.

If using std::set<> STL already provides union/intersection/difference algorithms. [But I'm not sure you need any of them.]

Topic archived. No new replies allowed.