@Test void testAllPermutationsOfAString() { assertThat(JackOfAllTrades.allPermutations("AABC")) .containsExactlyInAnyOrder("AABC", "AACB", "ABAC", "ABCA", "ACAB", "ACBA", "BAAC", "BACA", "BCAA", "CAAB", "CABA", "CBAA"); }
public static List<String> allPermutations(String str) { Map<Character, Integer> countMap = str.chars() .mapToObj(i -> (char) i) .collect(collectingAndThen(toMap(identity(), i -> 1, (i, j) -> i + j, TreeMap::new), Collections::unmodifiableMap)); return allPermutations(countMap, 0, str); }
JackOfAllTrades { public static List<String> allPermutations(String str) { Map<Character, Integer> countMap = str.chars() .mapToObj(i -> (char) i) .collect(collectingAndThen(toMap(identity(), i -> 1, (i, j) -> i + j, TreeMap::new), Collections::unmodifiableMap)); return allPermutations(countMap, 0, str); } }
JackOfAllTrades { public static List<String> allPermutations(String str) { Map<Character, Integer> countMap = str.chars() .mapToObj(i -> (char) i) .collect(collectingAndThen(toMap(identity(), i -> 1, (i, j) -> i + j, TreeMap::new), Collections::unmodifiableMap)); return allPermutations(countMap, 0, str); }  }
JackOfAllTrades { public static List<String> allPermutations(String str) { Map<Character, Integer> countMap = str.chars() .mapToObj(i -> (char) i) .collect(collectingAndThen(toMap(identity(), i -> 1, (i, j) -> i + j, TreeMap::new), Collections::unmodifiableMap)); return allPermutations(countMap, 0, str); }  static List<String> allPermutations(String str); }
JackOfAllTrades { public static List<String> allPermutations(String str) { Map<Character, Integer> countMap = str.chars() .mapToObj(i -> (char) i) .collect(collectingAndThen(toMap(identity(), i -> 1, (i, j) -> i + j, TreeMap::new), Collections::unmodifiableMap)); return allPermutations(countMap, 0, str); }  static List<String> allPermutations(String str);  }