Valid (byte to byte identical) answer not accepted

Couldn’t find anything similar with search. May be this though but then it needs a fix.

I am solving puzzle of the week (“CodinDice”). Issue is not specific to the task but I want to note this in case it’s a puzzle bug. The issue is my output (properly sent to stdout) is ignored.

Consider:

String s = solveit();
System.err.printf(“Answer: “%s”\n”, s);
System.out.println(s);

Output:

Answer: “0 LEFT”
0 LEFT
Failure
Found: Nothing
Expected: “0”

This doesn’t happen when the answer is “RIGHT”! Also, on sequence (0 LEFT, 0 RIGHT) I get:

Answer: “0 LEFT”
0 LEFT
Answer: “0 RIGHT”
0 RIGHT
Failure
Found: “0 R”
Expected: “0 D”

Note “0 LEFT” is ignored. One time I even got this:

Answer: “0 LEFT”
0 LEFTAnswer: "
0 RIGHT"
0 RIGHT

Given my code is not multi-threaded I am confused.

I also did this:

final byte[] utf8Bytes1 = s.getBytes(“UTF-8”);
final byte[] utf8Bytes2 = “0 LEFT”.getBytes(“UTF-8”);
System.err.printf("%d and %d, %b\n", utf8Bytes1.length, utf8Bytes2.length, Arrays.equals(utf8Bytes1, utf8Bytes2));

Result:

Answer: “0 LEFT”
6 and 6, true
0 LEFT
Failure
Found: Nothing
Expected: 0

Any ideas?

  1. Resetting code to default and copy-pasting back didn’t help.
  2. There is no other System.out… anywhere in the code.

Reduced to the following:

This works:

    String s = String.format("%d %s", 0, Movedir.LEFT);
    System.out.println(s);

This fails:

    List<String> result = new ArrayList<>();
    result.add(String.format("%d %s", 0, Movedir.LEFT));
    for (String s : result) {
        System.err.printf("Answer: \"%s\"\n", s);
        System.out.println(s);
    }

Movedir is:

enum Movedir {LEFT, RIGHT, UP, DOWN}

Further reduced to:

    List<String> result = new ArrayList<>();
    result.add("0 LEFT");
    for (String s : result) {
        System.out.println(s);
    }

Result:

Failure
Found: Nothing
Expected: “0”

This is test 2.

pinging contributor: @BlitzProg.

Sorted. Rolling dice in a direction only rolls it by one cell. Not super clear from the task, and the error message is misleading.

Hey! Sorry if you had trouble with it. Also didn’t notice the pinging, maybe there is some settings I need to adjust…

You can find the exact output required by a particular test case by clicking the icon on the top right of the test window box. The test case list will show up and you can click on whichever tests you’re interested in :slight_smile:
I especially recommend to do that on this puzzle because it is a very difficult one and potentially very confusing.

Codingame proceeds to compare naively char-by-char your output with the test cases and immediately stop at the first error. I agree it’s a bit annoying to understand when you’re not used to it, but it is very accurate. :smiley: