title: Java Sudoku Solution Verifier
body: <p>I am currently attempting to create a Java program that reads 81 integers (1-9) into an 9 X 9 matrix, and then tests to see if that matrix is a solution to a Sudoku puzzle. The parameters for a Sudoku solution are as follows: each number (1-9) must be represented in every row, column, and 3x3 square without any repetition in these areas. I have written a method to verify that the parameters are met for all rows and columns, however, I am struggling with coming up with an algorithm to verify the squares. Here is what I have so far:</p>
  
  <pre><code>import java.util.*;
  public class SudokuCheck
  {
    public static boolean sudokuCheck(int[][] s)
    {
      for(int row=0;row&lt;9;row++)
        for(int col=0;col&lt;8;col++)
        if(s[row][col]==s[row][col+1]){
        return false;}
       //Verifies rows
  
      for(int col2=0;col2&lt;9;col2++)
        for(int row2=0;row2&lt;8;row2++)
        if (s[row2][col2]==s[row2+1][col2])
        return false;
      //verifies columns
  
      return true;    
    }
  
  
    public static void main (String[] args)
    {
      Scanner input = new Scanner(System.in);
  
      int[][] solution = new int [9][9];
      System.out.println("Enter the values of a 9 X 9 Sudoku solution");
  
      for(int i=0;i&lt;9;i++)
        for(int j=0;j&lt;9;j++)
        solution[i][j]=input.nextInt();
      //read values into matrix
  
  
      if(sudokuCheck(solution)==true)
        System.out.println("The entered 9 X 9 grid is a solution to a Sudoku puzzle.");
  else
    System.out.println("The entered 9 X 9 grid is not a solution to a Sudoku puzzle.");
    }
  }
  </code></pre>