@Test public void testSortLetters() { assertEquals("act", AnagramDictionary.sortLetters("cat")); assertEquals("abcde", AnagramDictionary.sortLetters("abcde")); assertEquals("abcde", AnagramDictionary.sortLetters("edcba")); assertNotEquals("abcde", AnagramDictionary.sortLetters("abcdef")); }
@VisibleForTesting static String sortLetters(String input) { char[] chars = input.toCharArray(); Arrays.sort(chars); String result = ""; for (char c : chars) { result += c; } return result; }
AnagramDictionary { @VisibleForTesting static String sortLetters(String input) { char[] chars = input.toCharArray(); Arrays.sort(chars); String result = ""; for (char c : chars) { result += c; } return result; } }
AnagramDictionary { @VisibleForTesting static String sortLetters(String input) { char[] chars = input.toCharArray(); Arrays.sort(chars); String result = ""; for (char c : chars) { result += c; } return result; } AnagramDictionary(InputStream wordListStream); @VisibleForTesting  AnagramDictionary(String[] words); }
AnagramDictionary { @VisibleForTesting static String sortLetters(String input) { char[] chars = input.toCharArray(); Arrays.sort(chars); String result = ""; for (char c : chars) { result += c; } return result; } AnagramDictionary(InputStream wordListStream); @VisibleForTesting  AnagramDictionary(String[] words); boolean isGoodWord(String word, String base); ArrayList<String> getAnagrams(String targetWord); ArrayList<String> getAnagramsWithOneMoreLetter(String word); String pickGoodStarterWord(); }
AnagramDictionary { @VisibleForTesting static String sortLetters(String input) { char[] chars = input.toCharArray(); Arrays.sort(chars); String result = ""; for (char c : chars) { result += c; } return result; } AnagramDictionary(InputStream wordListStream); @VisibleForTesting  AnagramDictionary(String[] words); boolean isGoodWord(String word, String base); ArrayList<String> getAnagrams(String targetWord); ArrayList<String> getAnagramsWithOneMoreLetter(String word); String pickGoodStarterWord();  }