@@ -0,0 +1,806 @@
+public class Problem1_5 %7B%0A  public static void main(String%5B%5D args) %7B%0A    System.out.println(compress(%22aabcccccaaa%22) + %22 should be a2blc5a3%22);%0A    System.out.println(compress(%22abca%22) + %22 should be abca%22);%0A  %7D%0A%0A  public static String compress(String s) %7B%0A    String maybe = compressMaybe(s);%0A    if (maybe.length() %3C s.length()) %7B%0A      return maybe;%0A    %7D%0A    return s;%0A  %7D%0A%0A  public static String compressMaybe(String s) %7B%0A    char%5B%5D ca = s.toCharArray();%0A%0A    StringBuilder ret = new StringBuilder();%0A%0A    char last = '%5C0';%0A    int ct = 0;%0A    for (char c : ca) %7B%0A      if (c == last) %7B%0A        ct++;%0A      %7D else %7B%0A        if (ct %3E 0) %7B%0A          ret.append(last).append(ct);%0A        %7D%0A%0A        last = c;%0A        ct = 1;%0A      %7D%0A    %7D%0A%0A    ret.append(last).append(ct);%0A%0A    return ret.toString();%0A  %7D%0A%7D%0A%0A

Problem 1_5 solution