I'm currently in the process of coding a Sudoku Game. When running the program, it reads in a file (that I named 'myGame.txt' that looks like this:
1 2 3 4 5 6 7 8 9
|
7 2 3 0 0 0 1 5 9
6 0 0 3 0 2 0 0 8
8 0 0 0 1 0 0 0 2
0 7 0 6 5 4 0 2 0
0 0 4 2 0 7 3 0 0
0 5 0 9 3 1 0 4 0
5 0 0 0 7 0 0 0 3
4 0 0 1 0 3 0 0 6
9 3 2 0 0 0 7 1 4
|
Then, the program allows you to do some various things (those aren't all completed yet). I'm having problems with two things:
1) According to the rules of Sudoku, a value that the user inputs cannot be in the same 3x3 grid, row, or column that the user selects. For example, if the user inputs the number '8' in square 'B2', it should get an error, because there is already an '8' in square 'I2'. I have absolutely no idea whatsoever how to compare a number that the user inputs with other rows, columns, and the little 3x3 region that it lies in.
2) When I select option 'E' in my program to edit a square, when I go back to view the game board by selecting 'D', it doesn't insert the number that I selected. Instead, it just messes up the game board by placing a space or something instead. What am I doing wrong?
I'll place my code in another post, because this code is getting too long. Thank you!