How do test Java interactive solution in general?

I tried following two steps locally but it hangs. Submit the solution I got TLE.

> javac GolfGophers.java
> python interactive_runner.py python GolfGophers_testing_tool.py 0 -- java 
> GolfGophers

The Java code:
  static void judge(Scanner in, int[] input, int[] output) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 18; i++) {
      sb.append(input[i] + " ");
    }
    System.out.println(sb.toString());
    System.out.flush();
    for (int i = 0; i < 18; i++) {
      output[i] = in.nextInt();
      System.err.println(output[i]);
    }
  }

  static int judge(Scanner in, int count) {
    System.out.println(count);
    System.out.flush();
    return in.nextInt();
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int T = in.nextInt();
    for (int t = 1; t <= T; t++) {
      int N = in.nextInt();
      int M = in.nextInt();
      Map<Integer, Integer> sumcounts = new HashMap<>();
      int[] input = new int[18];
      int[] output = new int[18];
      for (int k = 0; k < Math.min(N, 100); k++) {
        for (int i = 0; i < 18; i++) {
          input[i] = 18;
        }
        judge(in, input, output);
        int sum = 0;
        for (int i = 0; i < 18; i++) {
          sum += output[i];
        }
        sumcounts.put(sum, sumcounts.getOrDefault(sum, 0)+1);
      }
      // sort sumcounts by value
      TreeMap<Integer, Integer> sortedMap = new TreeMap<>(new 
ValueComparator(sumcounts));
      sortedMap.putAll(sumcounts);
      int response = judge(in, sortedMap.firstKey());
    }
    in.close();
  }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/58fe0d5e-1677-4b6e-bd78-cc4a1ed041bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to