Yes, i understand it and solve puzzle, thanks.
HELP!!!
What i can do it when the generator has posicion 11 and the clone only can move to posicion 12? In this case, if the clone do a āWAITā is destroyed by the laser, if do a āBLOCKā the clone block the generator
If I remember well, you can āBLOCKā on top of a generator, it will just change the direction of clones, not block them.
The generator is in the posicion 11 and the leader clone it blocked in the posicion 12(last posicition before the laser), then the game over because the clone blocked not allow exit de ohters clones of the generartor.
From the rules: " It also changes direction when getting out of the generator directly on a blocked clone"
To help you on your problem: If you block your leading clone very soon, it is possible that for a few turns, there will be no leading clone. Looking at the replay where it fails, I donāt think your code handles it. Analyze the test āU turnā in IDE: why do you wait so long before blocking the leading clone to enable the U turn? This should put you on the right trackā¦
i passed all the testcase at first (testing before submitting), but when i submit the code, it didnt pass the U turn test but passed all others
any help ?
nevermind
started my code from scratch and solved it already
Hello Guys,
Test case 6.of this puzzle allows only 48 moves to me shouldnāt that be 53 moves otherwise its next to impossible to clear that test case.
Test case 7.of this puzzle allows only 42 moves to me shouldnāt that be 55 moves otherwise its next to impossible to clear that test case.
I have my reasons for that because the since there are 10 floors, ninth clone will the exit point (correct me if I am wrong). It takes 3 moves for any clone to move up a floor after it appears and the ninth clone come at 26th move and moving up 9 floor should take 27 moves to reach the exit.
Can someone please help me to understand how can i get to the exit in 48 moves ? Anyone please ?
I was having a hard time on this one, me as a newcomer to programming in C# and also it can be months between each practice since i mainly do PLC programming for work, i forget alot in C# in between.
Anyways, i managed to solve the first 5 with just 1 IF and 1 else, last 2 where there is a less amount of turns given it makes things trickier again
Will see if i can manage to figure it out without adding to much complexity to it.
I always try to find the shortest solutions, although it might not be the best. But if someone feel like giving some tips i gladly take them =)
Hello Guys/Girls;
i have a problem. Iām trying to solve this puzzle in java.
Here is my code: Dont Panic Episode 1
The code fails with more than 2 Floors. Somehow the āBlockā command doesnāt execute after the robots reach the 3 floor.
The problem occurs with test case > 3.
Edit: I located the mistake. Itās not allowed to print āWAITā and āBLOCKā in the same game round. After i seperated the command with āif/elseā everything works.
just FYI, this will be the case for every game with a while loop. You have to print just one output. Else the second will be taken for the next iteration of the loop but input will be out of sync with your output.
This puzzle reminded me of an old game I played 10ās of years ago, called Lemmings.
I simply had the clone turn block if it got to close to the edge:
if (clonePos > width -2){System.out.println(āBLOCKā);}
else if (clonePos < 1){System.out.println(āBLOCKā);}
else {System.out.println(āWAITā);}// action: WAIT or BLOCK
However, that only worked for the first few levels. Then I put in level qualifiers:
if (nbFloors < 3){
if (clonePos > width -2){System.out.println("BLOCK");}
else if (clonePos < 1){System.out.println("BLOCK");}
else {System.out.println("WAIT");}// action: WAIT or BLOCK
}else if(nbFloors > 8){
if (clonePos > width /2){System.out.println("BLOCK");}
else if (cloneFloor > 1 & clonePos < width /2 -2){System.out.println("BLOCK");}
else {System.out.println("WAIT");}// action: WAIT or BLOCK
}else{
if (clonePos > width /2 +7){System.out.println("BLOCK");}
else if (clonePos < width /2 -10){System.out.println("BLOCK");}
else {System.out.println("WAIT");// action: WAIT or BLOCK
}
}
However, then I got stuck on the level that didnāt give enough time/cycles to allow for lazy logic. So Iām working on a different approach.
What about blocking directly if you know the lead clone is going in the wrong direction? Good luck!
Having some issues with 6 and 7 test cases (in C++).
I get an exception at the line : cin >> cloneFloor >> clonePos >> direction; (which was in the generated code) :
*** Error in `/tmp/Answerā: free(): invalid next size (fast): 0x0000000000604060 ***
Aborted.
at abort.c. function __GI_abort () on line 89
at malloc.c. function malloc_printerr (action=1, str=0x7ffff6b1d3d0 āfree(): invalid next size (fast)ā, ptr=<optimized out>) on line 4996
i tried a getline to check the whole stream cin but same error.
Any help on this ?
Thanks
Hi, I have problem with āDonāt panic part 1ā. 3 last test give me incorrect position of elevators. I check it by output position of elevators to console.
I donāt understand, why have I got only 5 in Errors Stream and why is there 5 if i expected 8?
var inputs = readline().split(' ');
var nbFloors = parseInt(inputs[0]); // number of floors
var width = parseInt(inputs[1]); // width of the area
var nbRounds = parseInt(inputs[2]); // maximum number of rounds
var exitFloor = parseInt(inputs[3]); // floor on which the exit is found
var exitPos = parseInt(inputs[4]); // position of the exit on its floor
var nbTotalClones = parseInt(inputs[5]); // number of generated clones
var nbAdditionalElevators = parseInt(inputs[6]); // ignore (always zero)
var nbElevators = parseInt(inputs[7]); // number of elevators
var elevators = 5;
for (var i = 0; i < nbElevators; i++) {
var inputs = readline().split(' ');
var elevatorFloor = parseInt(inputs[0]); // floor on which this elevator is found
var elevatorPos = parseInt(inputs[1]); // position of the elevator on its floor
printErr(elevatorFloor +" "+ elevatorPos);
elevators = 8;
}
printErr(elevators); // Why there is 5 ?
// game loop
var c = 0;
while (true) {
var inputs = readline().split(' ');
var cloneFloor = parseInt(inputs[0]); // floor of the leading clone
var clonePos = parseInt(inputs[1]); // position of the leading clone on its floor
var direction = inputs[2]; // direction of the leading clone: LEFT or RIGHT
// Write an action using print()
// To debug: printErr('Debug messages...');
if(++c < 3)
print('BLOCK'); // action: WAIT or BLOCK
else
print('WAIT'); // action: WAIT or BLOCK
}
Maybe you donāt enter in your loop ? did you check it on the first test (where there isnāt any elevator) ?
Hey guys!
Iāve been working on a solution for quite some time on this one, and iām getting close to an answer (succeded cases nĀ°2,4,6 and 7). The last problem I have is that my code identifies immediately if a change of direction is needed, and therefore blocks the leading clone at round1 for test nĀ°1, 3 and 5. As the next clone hasnāt arrived yet, it generates an exception and crashes the testcase.
Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
Anybody got that one too and know how to solve it?
Thanks
1st rule of CodinGame: read carefully 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. In this case, you may output action WAIT.