static boolean isValid ( int c [ ] [ ] , int n ) {
  int X [ ] = {
    0 , - 1 , 0 , 1 };
    int Y [ ] = {
      1 , 0 , - 1 , 0 };
      boolean isValid = true ;
      for ( int i = 0 ;
      i < n ;
      i ++ ) {
        for ( int j = 0 ;
        j < n ;
        j ++ ) {
          for ( int k = 0 ;
          k < 4 ;
          k ++ ) {
            int newX = i + X [ k ] ;
            int newY = j + Y [ k ] ;
            if ( newX < n && newY < n && newX >= 0 && newY >= 0 && c [ newX ] [ newY ] == c [ i ] [ j ] ) {
              isValid = false ;
            }
          }
        }
      }
      return isValid ;
    }
    
static boolean isValid ( int c [ ] [ ] , int n ) { int X [ ] = { 0 , - 1 , 0 , 1 } ; int Y [ ] = { 1 , 0 , - 1 , 0 } ; boolean isValid = true ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < 4 ; k ++ ) { int newX = i + X [ k ] ; int newY = j + Y [ k ] ; if ( newX < n && newY < n && newX >= 0 && newY >= 0 && c [ newX ] [ newY ] == c [ i ] [ j ] ) { isValid = false ; } } } } return isValid ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal)))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))))))))))) (return_statement (identifier))))