[Community Puzzle] Rooks Movements

https://www.codingame.com/training/easy/rooks-movements

I can’t get the 100% because of the validator named “ANYBODY IN THERE”
Everything else is OK except this edge-test.

What is the content of this test or at least the main idea ?

It’s testing the same thing as the first test case - other units on the board but not blocking your rook.

I pass the first test case without efforts, so I’m clueless on this issue with the validator.

I have exactly the same problem.
I can pass that cas if I force the number of pices to zero and just render the output without considering any input on piece positions. (But then of course, I fail all other cases)

Can one of you try again? There was an extra space at the end of the input lines on that validator.

Nope, still only 75% and its the first case that messes up things.
I have gone through my code multiple times, and can’t find anything wrong.
An extra space at the end would not affect my solution, I think.

I work in Python3 at the moment, if that could matter.

As far as i can see the input does contain linebreaks instead of spaces for the piece piece output. I get:

d5
2
0
c1
1
e8

instead of

d5
2
0 c1
1 e8

when i loop twice as often as the input for the number of pieces suggest.

Also the Output description is wrong, instead of

A list of space-separated combination

it should say

A list of combination, one per line,

or

A list of line-break seperated combination

I used an extra raw_input()+concat in case the input is incomplete.
Thanks you for the tip !

I don’t know for other languages, but in C++ you can replace this block in the given code sample:

for (int i = 0; i < nbPieces; i++)
{
    string onePiece;
    cin >> onePiece; cin.ignore();
}

By this:

for (int i = 0; i < nbPieces; i++)
{
    string onePiece;
    getline(cin, onePiece);
}

Or this:

for (int i = 0; i < nbPieces; i++)
{
    string color;
    cin >> color; cin.ignore();
    string position;
    cin >> position; cin.ignore();
}

It’ll make the program behave like described in the statement. If you don’t do this, cin will stop as soon as it comes across a space (or a line break), which is why you need twice as many iterations to get all the input.

I just ran the default code, seems fine to me (prints ANSWER, even if there are multiple lines to read). :confused:
The default code isn’t written as you see it, but generated from a template (as CodinGame supports a lot of languages).

Well, try to print the input without touching anything, you’ll see it misses half of it.

for (int i = 0; i < nbPieces; i++)
{
    string onePiece;
    cin >> onePiece; cin.ignore();
    cerr << onePiece << endl;
}

Of course, because you changed the default code to only read a part of the input.
Reset it and try again (top right corner).

image

2 Likes

:man_facepalming:

I must have removed the color for some reason and completely forgot about it. Thanks for pointing that out! Disregard everything I’ve said then.

Wait, actually I just checked my past VODs and I didn’t change the default code at all, there was no variable for the color when I first checked this puzzle a week ago: https://www.twitch.tv/videos/337816275?t=05h55m29s

That’s really weird because I’ve just tried the puzzle in incognito mode and on other browsers, the code sample is similar to your screenshot. Resetting the puzzle gives a correct code sample too.

There must have been some wizardry at work that day lol.

I noticed your comments on discord and fixed it but you’d logged off so I couldn’t let you know. Sorry for any confusion caused.

3 Likes

Oooooh, that explains everything then, there was no magic after all :(.

Well, thanks for fixing it Robostac!

1 Like

Hi everyone, I’m squatting this thread instead of creating a new one.

I too have an issue with validators on this one, my code (obviously not hard coded) passes all manual tests with flying colors but only get 25% on the validation ones. The first one is green but not the others and I’m puzzled as of why. I’m confident the number 2 and 3 should be good, I may have an issue with output sorting on the last case if we have several pieces we can take since it’s not tested by default (but I’m 99% sure it should be ok)

I’m using PHP if it helps…

Thanks in advance for the help.

Hello guys,

I’m not able to pass the test CLOSE TO THE EDGE 2. The test CLOSE TO THE EDGE inside the IDE is not a problem. I tried all kinds of input pieces and I always receive a correct output from my point of view.
Can someone tell me how the second test validator could be different? I am really clueless at the moment…

Greetings,
Chris

Did you manage to get 100% for the IDE tests? I advise to pass all tests in IDE first. If you still have an issue, I can send you the validator by PM.

Hi Thibaud,
thanks for answering! Like you suggested, I improved to get 100% for the IDE tests. Now similiar to my first problem, I am failing in FOR FRODOOO 2. I would be really grateful for the validator (I just hate to have unfinished “work” :sweat_smile: )