Don't Panic - Episode 1 - Puzzle discussion

Hello,

Should be really straight forward, however I cannot understand why I cannot get the easy ones to work, while the difficult ones succeed. 1,3,5 not working
e.g. works:
Spaced elevators, few rounds
e.g. does not work.
U Turn

How can I manage turns for this challenge? Seems there are no clones available in time.

As written in the puzzle statement:

If there is no leading clone, the line values are: -1 -1 NONE. This can happen only when the clones which are already outside are all blocked and the next clone is not out yet. In this case, you may output action WAIT.

Hello 5DN1L,

As per my code

//corner case that was mentioned. Leave as is.
if(cloneFloor == -1 && clonePos == -1 && direction=="NONE")
{
  Console.Error.WriteLine("Waiting for a clone to appear");
  action = "WAIT";
}

Debug output:

### Standard Error Stream:

RIGHT Setting floor: 0 blockage at: 9

Clone blocked at 9

ACTION: BLOCK

### Game information:

You block one clone. Next leading clone coming in 2 turns.
### Game information:

Timeout: the program did not provide 1 input lines in due time... You block one clone. Next leading clone coming in 2 turns.

First part of the code;

//constraints
            if(clonePos > 0  &&  clonePos < width)
            {
                var elevatorOnFloor = floors[cloneFloor,0];
                //Console.Error.WriteLine($"This floor {(cloneFloor == exitFloor? exitFloor: cloneFloor)}: elevator position:{(cloneFloor == exitFloor?exitPos:elevatorOnFloor)}");
                var elevator = cloneFloor == exitFloor
                                                ?exitPos
                                                :elevatorOnFloor;

                message.Clear(); // reset each turn? is this one turn? while true..
                
                //corner case that was mentioned. Leave as is.
                if(cloneFloor == -1 && clonePos == -1 && direction=="NONE")
                {
                    Console.Error.WriteLine("Waiting for a clone to appear");
                    action = "WAIT";
                }

So you tell meā€¦ the other conditions wonā€™t be fulfilled so I have to make the assumption that on the end it would do a:

Console.WriteLine(action);

Where action of course is ā€œWAITā€.

If clonePos > 0, then clonePos cannot be == -1.

Ah yesā€¦ thatā€™s true. Totally didnā€™t see it.
Solved it. Thanks for being my ā€˜duckā€™ to talk to.

One comment though; when running the tests one keeps failing. While I can see it succeeds if I run it individually.
So just decided to submit and than itā€™s a 100% (without achievement, so need to make better the code somehow)

I have a problerm it semmes in Javascript on the test case not working right:
Here my LOG:

Standard Error Stream:

cloneFloor: 3
clonePos: 6
floor to search: 3
position to search: 18
nearestElevatorPos: 18
block to LEFT
final operation: BLOCK

Standard Output Stream:

WAIT

Game information:

You do nothing.

The final operation: BLOCK is the log about the operation that i return in the console.log
But in the standar ouptut stream it continue to be WAIT.
The problem sems present only for the test case 5 for alla other test work fine

That means you have included different things in console.log and console.error. Either they are different variables or the same variable has been changed in between somehow.

Timeout: the program did not provide 1 input lines in due timeā€¦

Am I the only one with this problem?

Probably not, but the problem will be very likely caused by some issue in your code. Possible reasons:

  • Your code does not output anything before reading the next set of inputs.
  • Your code does not output within the permitted time limit, e.g. your code is stuck in an infinite loop or your code is not efficient enough.

It looks like there is a bug in the data, at least for python 3. On the larger problems, the el_floor and el_pos are getting swapped sometimes. It started with 6 floors, lots of rounds.
Hereā€™s all of the data received:
7 24 200 6 17 40 0 6
1 10
12 5
2 6
0 14
4 15
18 3
The second and last elevators are definitely swapped, because those floor numbers are higher than the max. I swapped those and made it past, but then on the last test, thereā€™s another problem:
9 24 54 8 12 40 0 8
1 15
9 5
2 11
0 13
4 7
2 7
9 3
6 7
It has multiple entries for the same floor, so some of those are swapped. Both of the floor 9 ones are higher than possible, so my swap for if the floor was too high worked, but it also has two floor 2 entries. Looking at it, the second one is the swapped one, since 11 on the first one is too high, and Iā€™m missing floor 7. I put in code to swap the floor and pos if I already had the floor defined, and it worked for the test cases.

This wouldnā€™t be that much of a problem if it wasnā€™t also happening in the real test cases. I have no way to figure out what happened on those. It looks like the same problems since I have to have the code that checks for the floor being too high and swap the floor and pos to make it past the 6 floors lots of rounds there, and itā€™s failing on the last one there. Iā€™m guessing itā€™s the same problem where it had a swapped set that where pos was lower than the max floor, except that it most have given that one before the real one for that floor.

Thereā€™s probably a bug in your code when reading/storing/printing the input. I use Python too, and my code prints out the data received (correctly) as follows:

7 24 200 6 17 40 0 6
1 10
5 12
2 6
0 14
4 15
3 18

and

9 24 54 8 12 40 0 8
1 15
5 9
2 11
0 13
4 7
7 2
3 9
6 7

Try getting and printing the input first before you do anything else to it:

inputs = input()
print(inputs, file=sys.stderr, flush=True)
[other code to process inputs]

Ok Thanks.
I checked the original code vs what I had and the only difference was:
elevator_floor, elevator_pos = [int(j) for j in input().split()]
and I had:
el_floor,el_pos ={int(j) for j in input().split()}

Swapping the { } to [ ] did fix it. Iā€™m not sure why it would swap the values sometimes. I see that what I was doing was putting it into a set instead of a tuple, and testing it, it seems to randomly swap the values.

Sets do not preserve the order of the elements added to them.

The hardest part of this puzzle is reading the instructions and information given correctly.

I did not see we were given the elevator positionsā€¦

Something is bugged here. Somehow the clone appears on floor -1. So when I try to check if they are on the exit floor, it fails to do the check. How is it possible that the clone is on a non positive number?

With reference to the statement.

If there is no leading clone, the line values are: -1 -1 NONE. This can happen only when the clones which are already outside are all blocked and the next clone is not out yet.

EDIT
Ok, figured it out thanks to one of the other people struggling pointing out the problem. Weird rule is weird.

I am confused about this U Turn test case. I am using the following logic to determine when the lead clone should block:

bool ShouldBlock(int currentFloor, int clonePos, int currentDistanceToExit, int startingDistanceToExit) =>
    clonePos == 0
    || clonePos == width - 1
    || (currentFloor > 0 && currentDistanceToExit > startingDistanceToExit)
    || currentDistanceToExit == startingDistanceToExit + 2; //Allow space to exit on starting floor

On the replay it shows the starting gate one position further to the right than in the regular test case which puts it right next to the laser or width - 2. So, of course, the lead clone blocks too early at width - 1 but the only other option is to just walk into the laser at position width? What am I missing here?

Same problem

Python
I just donā€™t seem to manage. The first few floors work, afterwards it blocks a few steps more to the left and right of the elevator and one higher, it goes completely wild.
My code is longer then quoted below, but it is the most important part regarding the elevators; Can someone help me out?

The list is just all the positions of the elevators, sorted (e.g. [ [floor, pos], [ floor, pos], etc.]

if list[clone_floor][1] > clone_pos and direction == 'LEFT':
            print("BLOCK") 
if list[clone_floor][1] < clone_pos and direction == 'RIGHT':
            print("BLOCK")

Could you please also

  • state the name of the test you are failing, and
  • share the link of the replay here (you can find the button at the bottom right of the viewer)?