<awangdev>Cracking the Safe_1.java
public String crackSafe(int n, int k) {
        
        Set<String> set = new HashSet<>();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < n; i++) sb.append("0");
        set.add(sb.toString());
        
        for (int i = 0; i < Math.pow(k, n); i++) {
            String tail = sb.substring(sb.length() - n + 1); 
            for (int j = k - 1; j >= 0; j--) {
                String newStr = tail + j;
                if (!set.contains(newStr)) {
                    set.add(newStr);
                    sb.append(j);
                    break;
                }
            }
        }
        
        return sb.toString();
    }
public String var_0 ( int var_1 , int var_2 ) {
  Set < String > var_6 = new HashSet < > ( ) ;
  StringBuffer var_8 = new StringBuffer ( ) ;
  for ( int var_10 = 0 ;
  var_10 < var_1 ;
  var_10 ++ ) var_8 . append ( "0" ) ;
  var_6 . add ( var_8 . toString ( ) ) ;
  for ( int var_10 = 0 ;
  var_10 < Math . pow ( var_2 , var_1 ) ;
  var_10 ++ ) {
    String var_20 = var_8 . substring ( var_8 . length ( ) - var_1 + 1 ) ;
    for ( int var_21 = var_2 - 1 ;
    var_21 >= 0 ;
    var_21 -- ) {
      String var_22 = var_20 + var_21 ;
      if ( ! var_6 . contains ( var_22 ) ) {
        var_6 . add ( var_22 ) ;
        var_8 . append ( var_21 ) ;
        break ;
      }
    }
  }
  return var_8 . toString ( ) ;
}
