There is no Spoon - Episode 1 puzzle discussion


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?


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.


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.



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.


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. :slight_smile:


Ah oui en effet :slight_smile:
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? :unamused:

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


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;
    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. :slight_smile:


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

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 .

and the output is:
Standard Output Stream:
Game information:
So this is the first line…according to input what I get.