public static boolean tryUnscramble(Puzzle p,int key_int,byte[] solution){
  p.unscrambleKey[0]=(key_int / 1000) % 10;
  p.unscrambleKey[1]=(key_int / 100) % 10;
  p.unscrambleKey[2]=(key_int / 10) % 10;
  p.unscrambleKey[3]=(key_int / 1) % 10;
  for (int i=3; i >= 0; i--) {
    unscrambleString(p,solution);
    System.arraycopy(p.unscrambleBuf,0,solution,0,p.unscrambleBuf.length);
    unshiftString(p,solution,p.unscrambleKey[i]);
    for (int j=0; j < solution.length; j++) {
      int letter=(solution[j] & 0xFF) - p.unscrambleKey[j % 4];
      if (letter < 65) {
        letter+=26;
      }
      solution[j]=(byte)letter;
    }
  }
  if (p.solutionChecksum == (short)IO.cksum_region(solution,0,solution.length,0)) {
    int s=0;
    for (int i=0; i < p.getBoxesList().length; i++) {
      Box b=p.getBoxesList()[i];
      if (b != null) {
        b.setSolution((char)solution[s++]);
      }
    }
    return true;
  }
  return false;
}

public static boolean tryUnscramble ( Puzzle p , int key_int , byte [ ] solution ) { p . unscrambleKey [ 0 ] = ( key_int / 1000 ) % 10 ; p . unscrambleKey [ 1 ] = ( key_int / 100 ) % 10 ; p . unscrambleKey [ 2 ] = ( key_int / 10 ) % 10 ; p . unscrambleKey [ 3 ] = ( key_int / 1 ) % 10 ; for ( int i = 3 ; i >= 0 ; i -- ) { unscrambleString ( p , solution ) ; System . arraycopy ( p . unscrambleBuf , 0 , solution , 0 , p . unscrambleBuf . length ) ; unshiftString ( p , solution , p . unscrambleKey [ i ] ) ; for ( int j = 0 ; j < solution . length ; j ++ ) { int letter = ( solution [ j ] & 0xFF ) - p . unscrambleKey [ j % 4 ] ; if ( letter < 65 ) { letter += 26 ; } solution [ j ] = ( byte ) letter ; } } if ( p . solutionChecksum == ( short ) IO . cksum_region ( solution , 0 , solution . length , 0 ) ) { int s = 0 ; for ( int i = 0 ; i < p . getBoxesList ( ) . length ; i ++ ) { Box b = p . getBoxesList ( ) [ i ] ; if ( b != null ) { b . setSolution ( ( char ) solution [ s ++ ] ) ; } } return true ; } return false ; }
attempts to unscramble the solution using the input key . modifications to the solution array occur in place . if true , the unscrambled solution checksum is valid .
