[Community Puzzle] Rooks Movements

Thanks to Thibaud I was able to solve the puzzle.
For everyone who faces the same problem: Check what your program does when you have opponent pieces in both vertical and horizontal directions. Remember that the output always has to be in lexicographical order.

I’ve passed all the IDE tests but having an issue passing the validators “CLOSE TO THE EDGE 2” and “FOR FRODOOO 2” I’ve tried various starting positions for the rook near the board edges - corners, halfway points, and the output produced appears valid and I cannot figure out whats causing the validator fail, anyone have any ideas?

At the moment I consider tests for its puzzle is broken (see screenShot).CodeGame_Rook
It is impossible to pass.

The test is correct, the output section says “action should be x if the movement involves taking an opponent pieces, - otherwise”.

Agree. Thanks

Hi I have the same problem… Can you help me with FOR FRODOOO 2? Whatever I try it’s always the correct lexographical output.

In the first lines you should output where you can move to, in lexographical order. After that you should output where you can capture opponents, also in lexographical order. I recommend you to create a custom test scenario where you have multiple opponents which you can capture. Place the opponents in all possible directions and always check that the output respects the lexographical order.

1 Like

Hi, is there any way to see what a test case is? I am failing on FOR FRODOOO 2, but despite trying a load of custom tests I can’t find where the bug is.

What’s your output for this custom testcase:
g2
4
1 e2
1 g4
1 g1
1 h2

?

2 Likes

Thanks, I was missing Rg2-f2 and Rg2xe2. I had missed the condition where there was both a blocking piece on the right and left of the rook. I have 100% now :white_check_mark:

" For instance, if the white rook is in d5 and can move to d6 , then the output must be Rd5-d6 .
If the white rook is in e4 and can capture an opponent piece in e3 , then the output must be Re4xe3"

Closing the edge
a8
5
0 e8
1 d7
0 c6
1 b5
0 a4
Expected result:
Ra8-a5
Ra8-a6
Ra8-a7
Ra8-b8
Ra8-c8
Ra8-d8

My result:
Ra8-a5
Ra8-a6
Ra8-a7
Ra8-b8
Ra8-c8
Ra8-d8
Ra8xa4
Ra8xe8

This is a bug. Maybe I should learn elsewhere.

Guys who do it, i need your help. i can’t pass for frodoooo 2 but i pass for frofooo 1. wtf ?

Maybe you should stop your rook after an opponent piece or not eat a friendly piece?

But i pass all tests and my code do this things but after submit last test stop working.

Hello,
Did you solve this problem with Fredooo 2 ?
I have the same problem with it and also with Only allies 2 ;<
I tried a lot of custom cases and everything looks fine !

Can we get somehow the position used by the test “frodoooo 2” ?

edit : solved !
i corrected my code thanks to
g2
4
1 e2
1 g4
1 g1
1 h2

1 Like

On cell a4 and e8 have a white piece which means it is not an opponent piece for the white rook so you should not add the x for your resoult. It is not a bug.

@UPS This is the lexographical order, because ‘-’ is less/smaller than ‘x’.
That’s why you should print the simple steps before the movements involves taking an opponent pieces

I had a problem with the 3rd validation (ONLY ALLIES 2). To find the bug I had to use this testcase:

d2
5
0 e2
0 c2
0 g4
0 g1
0 h2

Hope, it will help somebody else too :slight_smile:

1 Like