public static bool CheckIfSudokuOK(int[,] tab) { NumberChecker checker = new NumberChecker(); // Checking rows for (int row = 0; row < SIZE; row++) { checker.Reset(); for (int col = 0; col < SIZE; col++) if (!checker.RegisterNumber(tab[row, col])) return false; } // Checking cols for (int col = 0; col < SIZE; col++) { checker.Reset(); for (int row = 0; row < SIZE; row++) if (!checker.RegisterNumber(tab[row, col])) return false; } // Checking squares for (int square = 0; square < SIZE; square++) { checker.Reset(); for (int position = 0; position < SIZE; position++) if (!checker.RegisterNumber(tab[(square / 3) * 3 + position / 3, (square % 3) * 3 + position % 3])) return false; } return true; }
public static bool CheckIfSudokuOK(int[,] tab) { NumberChecker checker = new NumberChecker(); // Checking rows for (int row = 0; row < SIZE; row++) { checker.Reset(); for (int col = 0; col < SIZE; col++) { if (!checker.RegisterNumber(tab[row, col])) { return(false); } } } // Checking cols for (int col = 0; col < SIZE; col++) { checker.Reset(); for (int row = 0; row < SIZE; row++) { if (!checker.RegisterNumber(tab[row, col])) { return(false); } } } // Checking squares for (int square = 0; square < SIZE; square++) { checker.Reset(); for (int position = 0; position < SIZE; position++) { if (!checker.RegisterNumber(tab[(square / 3) * 3 + position / 3, (square % 3) * 3 + position % 3])) { return(false); } } } return(true); }