Don't Panic - Episode 1 - Puzzle discussion

the problem is simple…
and it is on the elevators…

=> you set with i that is order of input

=> you use cloneFloor to get elevator position

but the elevators inputs are not sorted …

how do you do the first test case with the right or left code?

my name is alim i am 10 years old

hello :slightly_smiling_face:

ive passed all cases but 2 and 4

looks like this

cant understand the problem

elev[elevatorFloor]=elevatorPos;
is how i store my elevatorPos

(clonePos<elev[cloneFloor]&&direction.equals(L))||(clonePos>elev[cloneFloor]&&direction.equals®)
main if statment

help please

You should use debug print to understand why your clone is blocking on the wrong place.

umm im not sure what to print out…elevetorPos is right
and by setting it shouldnt stop
also the clone stops ON the elevator shouldnt it go up?

if you dont mind be more specific
thank you for the fast reply

The only variable data is clonePos, that is what you should debug print.
You will then understand why your clone stops on the elevator instead of going up.

passed all cases when changed

if(clonePos==0||clonePos==width--){
       System.out.println("BLOCK");
}

to :

if(clonePos==0||clonePos==width-1){
    System.out.println("BLOCK");
}

they should be the same no?

totally different …
“width - 1” => “width - 1”
“width --” => “width” and after it does “width = width - 1”

1 Like

I’ve passed 4, 6, 7 tests. But 5 fails. The clone reaches the 3d floor, then it doesn’t block (to change direction), although it should. Blocks 2 turns later (why? conditions change not). It’s strange, because of the 7th test is similar, but it have passed. What’s wrong?

Give me the solution bro

Ha ha ha ha.
No.

Anybody, please. Is it possible to pass the 7th test, but fail the 5th?

Since you fail test 5 in the IDE, I suggest you try to debug why your code doesn’t block the leading clone in time, because there is no way for us to guess what’s wrong in your code here. Use error prints without moderation :wink:

Yeah, I’ve tried. If(clonePos < elevatorPos) & & (direction == “LEFT”) { cout << “BLOCK” << endl;}, but it doesn’t. Then, two turns after it does. Conditions are the same. ALL other tests passed, including the 7th, which, as I realize, is more complicated version of the 5th.

I suggested to use debug prints to check the value of your variables when the block should occur.

I’ve understood :slight_smile: variables match the conditions above. Two turns after everything is the same. And it blocks. If the conditions didn’t work, the 7th test wouldn’t have passed.

if you print debug information in the condition, you can see that you enter it, although you code still prints WAIT.
It means the output is desynchronized from the input and that you’ve output multiple commands in a previous turn.

1 Like

Thnx a lot! I’ll try to solve this.
UPD. Done. Thnx again :slight_smile:

Hi, I have read some of you using path-based solution but I really think that blocking a clone when he is going in the wrong direction would just be enough and it would also be the best solution. When I am doing this, I found an error in the code in the fourth testcase “several floors” where I am printing “BLOCK” but the program makes “WAIT”

Standard Error Stream:

I blocked!

Standard Output Stream:

WAIT

Did you see this warning?

If you output multiple commands during a turn, only the first command will be taken into account during this turn. The others will be taken into account in the later turns, so what you will read in the input during these turns won’t correspond to what you’ve already printed in the output. Maybe we should edit that message a bit.