I wrap the execution with a bash script that basically looks like the
following:

a.sh

java Golf | tee output_dump

b.sh

python testing-tool.py | tee input_dump

Then I run

python interactive_runner.py b.sh -- a.sh

It basically copies output of both programs, while still running the
interactive tester.

-Sam


On Mon, Apr 15, 2019, 12:25 Marcel Ubach <[email protected]> wrote:

> El sábado, 13 de abril de 2019, 23:53:06 (UTC+2), [email protected]
> escribió:
> > 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're reading N and M for each test but the statement says they appear
> only once (in the first line together with T).
>
> About the general question of how to test the interactive tool with Java,
> I'm doing the same as you. When the solution is ok it's pretty useful but
> when something is wrong the execution hangs and it's hard to determine
> where's the bug. Let's see if somebody else has any suggestions.
>
> --
> 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/9c6f8692-de31-4225-ba3c-e008c5076231%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CACisUVVCxyhw0CkfUUzrNw6Axvx611gt5_kUbrcSqpe%2BH4sTnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to