Don't Panic - Episode 1 - Puzzle discussion

Tests and validators are slightly different. As can be seen in the replays you shared, the top elevator (on the floor below the exit) is located at a different position.

In the replay from Submit, can you see that the lead clone blocks at the top elevator? As a result, no clone is able to use it to go to the exit floor. That is where you want to further investigate and think about how to fix your code.

As can be seen in the replay, after travelling up the first elevator, the clones move right at first instead of moving left, and it takes many turns for them to return to the elevator on that floor. You have to fix your code so that the clones will always take the shortest route and won’t waste the turns.

1 Like

should i used the STRING DIRECTION (leftor right)?? , i don´t know how to use it, i apoligize im really stocked

The string direction tells you which direction the lead clone is moving. If that direction is the same as the direction you want for the shortest path, then fine; otherwise you would want to block that clone so that the next clone won’t go that direction.

I was assuming that in clone’s position 1 and elevator’s position 0 (and direction “LEFT”) I just return “WAIT” and clone will be moved up on next step.
After changing (expanding) comparisons to edge positions all is good.

1 Like

i really dontknow how to inclode the string direction (left or rgiht) on this code :frowning:

What do you mean? The directions are given to you as inputs, and you can use them in deciding what to output. You cannot output any directions - you’re required to output either WAIT or BLOCK only.

yes, thanks fr that, but im still stocked im sorry, should i used the elevator osition on each floor ? and how can i use that elevator position, should i read ir from each floor ?

You have to make use of the elevator positions in order to calculate the shortest path for the clones to take.

2 Likes

TSM, im going to find how can i call the variable elevatorPos from the FOR cicle and use it inside the WHILE cicle

1 Like

Check that you included the position of the exit and not just the elevators.
The exit has a separate variable and the “U Turn” test case only has a exit.
So if you did not set the goal point to the exit you will fail the testcase.

I attempted to do my solution in C++ but there was a bug with input related to elevators.

What bug? Please provide more details.

thank you. I was so confused why the elevators had confusing positions

Help. On the 3rd level, the game tells me that the only elevator is position 3 while it is in 1 in reality?

Position 3 refers to the horizontal position, and it is on floor 0. I don’t know where you get 1.

Hello. I have a question that I’m not sure if it’s about this precise puzzle or of codingame in general, as this is my first puzzle.

I have a logic that when the leading clone reaches a new level, it should BLOCK if a certain condition is met. In the test 4 “Several floors”, the first time that the clone gets to a new level it works fine: https://i.imgur.com/1L8AdgB.png
In the image you can see how the clone is on floor 0, moves to floor 1 and since he is moving right, make a BLOCK. The block is done in the same iteration (debug prints show “block 3” and sure enough the Standard Output Stream makes a BLOCK.

All good.

The issue comes when later on the clones encounter a similar situation. The leading clone gets to a new floor, checks if it needs to block and it does, so it calls BLOCK, but the BLOCK is not performed, instead a WAIT is called.
The next iteration then has the BLOCK, but why is it ignoring the first BLOCK call?
https://i.imgur.com/aeHADZ1.png In this image you can see how upon reaching floor 2, block 4 is called but the code instead makes a WAIT.

The more floors it has, the worse it gets. Her is another example
Here floor 4 is reached and block 3 is called. This call is ignored 4 times until the 5th when finally, after having called “block 3” for four iterations, the fifth one makes a BLOCK: https://i.imgur.com/CSrwlM8.png

Is this a coding issue of mine or is there a caveat I’m not aware of?

Thanks!

Your image links don’t work on my computer. Would you please share the link to the replay instead (you can find the button in the bottom right corner of the viewer)?

Oh sorry, didn’t know there was a replay button.

here it is: Coding Games and Programming Challenges to Code Better

in a nutshell this is called but despite running this code and printing the debug “block 3” (or 4 depending of the if) the code is still running a WAIT.

if(...){
                    cout << "BLOCK" << endl;
                    cerr << "block 3" << endl;
}

output:

Standard Error Stream:
same Floor: 2
pos portal: 19
pos player: 4
direction: LEFT
block 4
Standard Output Stream:
WAIT
Game information:
You do nothing.