Once again, I'm having trouble with my Sudoku Game. This is the last part and I'm almost there! I just need a little bit of help. According to the rules of Sudoku, there can only be once instance of each value in each column, row, and 3x3 grid. I'm writing a function which will tell you the possible values you can input in each spot. I'm having problems.
What I'm trying to do is write all the values of the row into one array, and then all the values of the column into another array. Then, compare the two arrays and output the numbers that don't exist in either of the two. This is what I have so far:
//Declare variables
char letter;
int number;
int rowNotPossibles[9];
int colNotPossibles[9];
int possibles[] = {1,2,3,4,5,6,7,8,9};
//Gets letter/number coordinates
cout << "What are the coordinates of the square: ";
cin >> letter >> number;
//Converts letter to uppercase otherwise
//ASCII conversion in next step won't work
letter = toupper(letter);
//If square is not equal to zero, display "read only" message
if (sudokuBoard[letter - 65][number - 1] != 0)
{
cout << "ERROR: Square \'" << letter << number << "\' is read-only\n";
cout << "\n";
getOption(sudokuBoard);
}
else
{
//Gets the current column and row
int currentColumn = (letter - 65);
int currentRow = (number - 1);
for (int i = 0; i < 9; i++)
{
colNotPossibles[i] = sudokuBoard[i][currentColumn];
rowNotPossibles[i] = sudokuBoard[currentRow][i];
}
}
//Displays the possible values based on the coordinates the user entered
cout << "The possible values for \'" << letter << number << "\' are: ";
cout << "\n\n";
getOption(sudokuBoard);
}
I'm lost. Any help? I'm also absolutely completely and entirely clueless on how to compare it to a 3x3 grid. Any help on that would be greatly appreciated, also. Thank you in advance!