rendered paste body static String[] permute(String str) { int len = str.length(); if (len > 2) { String[][] result = new String[len][len-1]; for (int i = 0; i < len; i++) { String help = str.substring(0, i) + str.substring(i+1); String[] permhelp = permute(help); // Rekursion for (int j = 0; j < len-1; j++) result[i][j] = str.charAt(i) + permhelp[j]; } String[] result2 = new String[fak(len)]; int k = 0; for (int i = 0; i < len; i++) for (int j = 0; j < len-1; j++) { result2[k] = result[i][j]; k++; } return result2; } return result3[0]=str; }