fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11. public static String blowup(String str) {
  12. StringBuilder sb = new StringBuilder();
  13. int repeat = -1;
  14. for (char c : str.toCharArray()) {
  15. if (repeat < 0 && Character.isDigit(c)) {
  16. repeat = Character.getNumericValue(c);
  17. } else {
  18. do {
  19. sb.append(c);
  20. } while (--repeat >= 0);
  21. }
  22. }
  23. return sb.toString();
  24. }
  25.  
  26. public static void main (String[] args) throws java.lang.Exception
  27. {
  28. System.out.println(blowup("a3tx2z"));
  29. System.out.println(blowup("a3tx03112z"));
  30. }
  31. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
attttxzzz
attttx311zzz