private void validate(int[][] b){
  int found[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  StringBuilder bs=new StringBuilder();
  for (int r=0; r <= MaxR; r++) {
    for (int c=0; c <= MaxC; c++) {
      found[b[r][c]]=1;
      bs.append(b[r][c]);
    }
    bs.append('|');
  }
  for (int i=0; i < found.length; i++) {
    if (found[i] == 0) {
      throw new IllegalArgumentException("Illegal board state:" + bs);
    }
  }
}

private void validate ( int [ ] [ ] b ) { int found [ ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; StringBuilder bs = new StringBuilder ( ) ; for ( int r = 0 ; r <= MaxR ; r ++ ) { for ( int c = 0 ; c <= MaxC ; c ++ ) { found [ b [ r ] [ c ] ] = 1 ; bs . append ( b [ r ] [ c ] ) ; } bs . append ( '|' ) ; } for ( int i = 0 ; i < found . length ; i ++ ) { if ( found [ i ] == 0 ) { throw new IllegalArgumentException ( "Illegal board state:" + bs ) ; } } }
validate the board state . an illegalargumentexception is thrown if the board is an invalid representation of the puzzle .
