private static boolean run ( final char [ ] s , final int [ ] d1 , final int [ ] d , final int k ) {
  if ( k == s . length ) {
    for ( int i = 1 ;
    i < 10 ;
    ++ i ) {
      if ( d1 [ i ] != d [ i ] ) {
        return false ;
      }
    }
    return true ;
  }
  while ( true ) {
    char c = s [ k ] ;
    if ( c > '9' ) {
      s [ k ] = '0' ;
      return false ;
    }
    int x = c - '0' ;
    if ( d1 [ x ] < d [ x ] ) {
      ++ d1 [ x ] ;
      if ( run ( s , d1 , d , k + 1 ) ) {
        return true ;
      }
      -- d1 [ x ] ;
    }
    ++ s [ k ] ;
  }
}

private static boolean run ( final char [ ] s , final int [ ] d1 , final int [ ] d , final int k ) { if ( k == s . length ) { for ( int i = 1 ; i < 10 ; ++ i ) { if ( d1 [ i ] != d [ i ] ) { return false ; } } return true ; } while ( true ) { char c = s [ k ] ; if ( c > '9' ) { s [ k ] = '0' ; return false ; } int x = c - '0' ; if ( d1 [ x ] < d [ x ] ) { ++ d1 [ x ] ; if ( run ( s , d1 , d , k + 1 ) ) { return true ; } -- d1 [ x ] ; } ++ s [ k ] ; } }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter (modifiers) type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) consequence: (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 (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (return_statement (false)))))) (return_statement (true)))) (while_statement condition: (parenthesized_expression (true)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (character_literal))) (return_statement (false)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (character_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (block (return_statement (true)))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier))))))))