Source code for submission s966

Go to diff to previous submission

Bugs.java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package bugs;
  6.  
  7.  
  8. import java.io.BufferedReader;
  9. import java.io.IOException;
  10. import java.io.InputStreamReader;
  11. import java.util.ArrayList;
  12.  
  13. /**
  14.  *
  15.  * @author student
  16.  */
  17. public class Bugs {
  18.  
  19. /**
  20.   * @param args the command line arguments
  21.   */
  22. public static void main(String[] args) throws IOException {
  23. StringBuffer row = new StringBuffer(br.readLine());
  24.  
  25. ArrayList<String> rows = new ArrayList<String>();
  26.  
  27. while(row.length()>0) {
  28. Integer whiteChar = row.toString().indexOf(" ");
  29.  
  30. int rowCount = Integer.valueOf(row.substring(0, whiteChar));
  31. String text = row.substring(whiteChar+1, row.length());
  32.  
  33.  
  34.  
  35. for (int i = 0; i < rowCount; i++) {
  36. String row2 = br.readLine();
  37. String tmp = row2.replace(text, "");
  38. rows.add(tmp);
  39. }
  40. row = new StringBuffer(br.readLine());
  41. }
  42.  
  43. for (String r : rows) {
  44. System.out.println(r);
  45. }
  46.  
  47. }
  48. }
  49.  

Diff to submission s954

Bugs.java

--- c4.s954.cteam124.bugs.java.0.Bugs.java
+++ c4.s966.cteam124.bugs.java.0.Bugs.java
@@ -28,15 +28,7 @@
         while(row.length()>0) {
             Integer whiteChar = row.toString().indexOf(" ");
-            String[] split = row.toString().split(" ");
             
-            int rowCount = 0;
-            String text;
-            if (split.length == 2) {
-                rowCount = Integer.parseInt(split[0]);
-                text= split[1];
-            } else {
-            rowCount = Integer.parseInt(split[0]);
-                text= " ";
-            }
+            int rowCount = Integer.valueOf(row.substring(0, whiteChar));
+            String text = row.substring(whiteChar+1, row.length());