# Need help with a Sudoku verifying program

• 10-30-2009
Skeeter
Need help with a Sudoku verifying program
What I can see that we are dealing with is that I need to use multidimensional arrays.

I'm suppose to verify an input file with sudoku solutions, "sudoku-solution.c" is correct or not.

The input file is the following:

1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
2 3 4 5 6 7 8 9 1
5 6 7 8 9 1 2 3 4
8 9 1 2 3 4 5 6 7
3 4 5 6 7 8 9 1 2
6 7 8 9 1 2 3 4 5
9 1 2 3 4 5 6 7 8

So far what I have is

Code:

```#include <stdio.h> FILE *fp; int main() {         int i, sudoku[9][9];                 fp = fopen("sudoku-solution.txt","r");                         for(i=1;i<10;i++)         {         fscanf(fp,"%d", &sudoku[9][i]);         }                 for(i=1;i<10;i++)         printf("%d", sudoku[2][i]);         }```
I did this to test what my values I'm scanning are. I'm just getting the first row, any tips on how I should go about doing this? I'm think that I should verify that each row vertically and horizontally add up to 45. Is there a way to print values vertically? Also is there a way to the values in the next row?

Thanks
• 10-30-2009
Dino
I'm not sure if adding up to 45 is a good enough test.
While

1+2+3+4+5+6+7+8+9 = 45,

so does

1+5+5+5+5+6+6+6+6 = 45
• 10-30-2009
quzah
Make three functions:

1. Test a row for 1 through 9.
2. Test a column for 1 through 9.
3. Test a 3x3 block for 1 through 9.

Quzah.
• 10-30-2009