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.
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.
//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:
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.
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:
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.
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?
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.
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?
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")