TaroString { public static String getAnswer(String input) { String returnValue = "Impossible"; int cIndex = -1; int aIndex = -1; int tIndex = -1; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); switch(c) { case 'C': if (cIndex != -1 || aIndex != -1 || tIndex != -1) return returnValue; cIndex = i; break; case 'A': if (cIndex == -1 || aIndex != -1 || tIndex != -1) return returnValue; aIndex = i; break; case 'T': if (cIndex == -1 || aIndex == -1 || tIndex != -1) return returnValue; tIndex = i; break; } } returnValue = "Possible"; return returnValue; }  static String getAnswer(String input);  }
@Test public void test3() { assertEquals(TaroString.getAnswer("ACBBAT"), "Impossible"); }
@Test public void test4() { assertEquals(TaroString.getAnswer("SGHDJHFIOPUFUHCHIOJBHAUINUIT"), "Possible"); }
@Test public void test5() { assertEquals(TaroString.getAnswer("CCCATT"), "Impossible"); }
@Test public void test1() { assertEquals(TaroString.getAnswer("XCYAZTX"), "Possible"); }
@Test public void test2() { assertEquals(TaroString.getAnswer("CTA"), "Impossible"); }