I might be missing something but the inputs in the test cases do not comply with the input definition in the description, namely they are missing:
Line 1: one integer width for the number of cells along the x axis.
Line 2: one integer height for the number of cells along the y axis.
Any suggestions for how to do this in one pass down a 2d for loop or something faster than a 2d for loop? If I do more than that my code is too slow. My last attempt was to print as soon as i insert something into the second row, and then work backwards. Has anyone had success with this?
PHP:
I failed Tunnel and Filled tests when i submitted my code. I submitted it again without changeing and it passed. It looks like parser problem, not the code.
Hi,
I have the same kind of problem in java. I havenât changed my code but the result of the submitting change. In the test âfilledâ it failed but not every time at the same node. The other tests work fine most of the time but from time to time one fail. I donât know what is the trouble.
Bonjour,
Je ne comprends pas, je valide tous les tests sauf : Horizontal, Carré, Complexe, Shuriken.
Il me semble que les tests ne sont pas bons.
Jâutilise un simple Array en Javascript.
Merci
Bonjour, tous les tests sont bons.
Debugguer ton algo sur Horizontal devrait ĂȘtre assez simple.
Merci de ta réponse.
Ma sortie standard est : 0 0 -1 -1 -1 -1 ce qui semble correspondre au schĂ©ma des nĆuds.
Et pourtant le jeu mâinforme : â(-1, -1) is not to the right of (0, 0). Expected (2, 0)â
La recherche des voisins ne se limite pas Ă la âcaseâ dâa cotĂ©. 0 0 Ă clairement un voisin de droite.
Ah oui en effet
Merci pour ton aide (je ne voyais pas mon erreur dans mon code, et câĂ©tait une erreur de comprĂ©hension de lâĂ©noncĂ© que je nâaurai pas rĂ©solu de si tĂŽt sans ta remarque).
Bon continuation.
How to solve?, using 2D array ?
How this code can reach the last return? How can it pass the if-else?
Output of Console.Error.WriteLine:
x:0 y:0 width:5 data[0,1]: .
x:1 y:0 width:5 data[0,2]: 0
x:2 y:0 width:5 data[0,3]: .
x:3 y:0 width:5 data[0,4]: 0
Stream Output:
0 0 NULL_X -1 -1
Code:
static string nextXnode(int x, int y, int width, string[,] data)
{
Console.Error.WriteLine("x:"+x+" y:"+y+" width:"+width+" data["+y+","+(x+1)+"]:"+data[y, x+1]);
if(x == width-1)
return " -1 -1";
if(data[y, x+1] == "0")
return " "+(x+1)+" "+y;
else
nextXnode(x+1, y, width, data);
return " NULL_X";
}
youâre calling nextXnode recursively but not doing anything with it.
Thank you! Didnt knew that a recursive call have to be returned. It works now.
I am stuck here guys. Iâm not really known with the speeds of certain code snippets. I have this code now what works for some testcases but for most of them the response is to slow.
var width = parseInt(readline()); // the number of cells on the X axis
var height = parseInt(readline()); // the number of cells on the Y axis
for (var i = 0; i < height; i++) {
for (var x = 0; x < width; x++) {
var line = readline(); // width characters, each either 0 or .
var x1 = "";
var y1 = "";
var x2 = "";
var y2 = "";
var x3 = "";
var y3 = "";
if (line == "0") {
x1 = x;
y1 = i;
x += 1;
if (line == "0") {
x2 = x;
y2 = i;
}
else {
x2 = -1;
y2 = -1;
}
x -= 1;
i += 1;
if (line == "0") {
x3 = x;
y3 = i;
}
else {
x3 = -1;
y3 = -1;
}
i -= 1;
print (x1 + " " + y1 + " " + x2 + " " + y2 + " " + x3 + " " + y3);
}
}
}
Can somebody tell me whatâs wrong? And maybe link me to some info about the process speeds of javascript codes.
Your problem is that you are reading the data without saving it. So really quickly your program try to read data that does not come any more, and just stick at the line 'var line = readline();
That is why it times out.
You should save the lines and parse them after.
Hey, some questions about the puzzle. Iâm looking to do it in C. Iâm just a little confuses by the starting code they give you. The for loop that picks up your starting values goes through [height] times and has an fgets grabbing [width] information. Iâm fine with that, but when accessing the information after arenât all the pointers used for fgets the same one? I guess Iâm confused as to why I donât need to malloc a big ol chunk of memory big enough for [height] x[width] after I collect those values.
Sorry if this has been asked before but how do I know which values are being passed when I run a test case?
I donât understand the input dataâŠ
in the horizontal:
According to the description the height mean the number of cells in the y axis.
In this case is only 1 instead of 5.
How could I know what the correct y coordinate?
in the vertical table is same just rotatedâŠ
the firs line only 0 instead of .0.
How could I know what the correct x coordinate?
If I not mistaken the grid always starts at 0,0
And Horinzontal is:
ââ
while Vertical is:
â
â
0â âx
â
â
y
Donât hesitate to click on the gear Icon to display the Settings of the replay and enable the DEBUG mode
This is my problem⊠I guess not start at 0,0.
in horizontal (02 case)
for (int i = 0; i < height; i++)
{
string line = Console.ReadLine(); // width characters, each either 0 or .
if(i==0)
{
Console.WriteLine(line);
}
}
and the output is:
Standard Output Stream:
0.0.0
Game information:
So this is the first lineâŠaccording to input what I get.