There is no Spoon - Episode 1 puzzle discussion


#136

Hi, I don’t know if this is the proper place to ask for tips or what, but I’ll try anyway :slight_smile:
I’m trying to solve it in python since it’s a language I don’t know and I’d like to learn.
Now, I achieve getting if the pointed “cell” is a node or not, I can tell if the adiacent one is either, but how do I tell right away if the one below is or not? At that point I don’t have the subsequent line yet.
It’s not even a real coding language since it doesn’t depend on java or python or whatever, I just don’t know how to play with data I don’t have :smiley:
What am I missing?

Thank you very much;

Roberto


#137

You can modify all the code that is given by default.
So instead of just reading the lines, you can store them in a list. Read all lines first and then start searching for neighbors.


#138

Hi there,
just a little question about the rule of this game:
if I have a “dot” (so no cell) in the grid, what do I have to print ?
Cause so far I made it print -1 -1 as there are no adjacent cell, but the programm tells me “invalide node”, so how do I skip a node ?
Thanks in advance


#139

You only have to output neighbor for node; so 0, don’t print anything for ‘.’


#140

Thanks for the answer,
my problem is that the “print” function has to occur at every iteration, so when I arrive on a empty cell (dot) I have to set x,y and the coordinates of the neighbour…
I don’t get how to say “if empty cell, no print”


#141

What do you mean by iterations?

Read input and build the map
In the map, find every node '0'
Foreach Node 
    Print Neighbors

#142

As I am searching each point of the grid (1 point = 1 iteration = 1 print), when I run on an empty cell I have to print something, and if i don’t the program tells me “coordinate not defined”…

I tried to store the coordinate on x and y of the “0” on 2 two separated lists and then looking for neighbors in x and y, but it takes too long…


#143

The second approach is a good start, if it’s “too” long (you timeout); it mostly because you have an infinite loop or whatsoever. You don’t have to optimize anything for medium/easy puzzle, you have plenty of time.


#144

Okay thanks I will continue on this path then and try to find my issue
Thanks for your answers


#145

Hi everyone, would someone tell me why the program answers me that it takes too long ?

    width = int(raw_input())  # the number of cells on the X axis
    height = int(raw_input())# the number of cells on the Y axis
    xnoeud=[]
    ynoeud=[]
    for y in xrange(height):
    line = raw_input()  # width characters, each either 0 or .
        for x in range(width):
           if line[x]==0:
             xnoeud.append(x)
             ynoeud.append(y)
           
    for i in ynoeud:
        for j in xnoeud:
           if (j+1) in xnoeud:
               x2=j+1
               y2=i
           else:
               x2=y2=-1
            
           if (i+1) in ynoeud:
               x3=j
               y3=i+1
          else:
               x3=y3=-1
            
       print i,j,x2,y2,x3,y3

Thank you


#146

line[x] is a character and you compare it with a integer so false => xnoeud & ynoeud are empty => you never reach your print statement => you timeout


#147

Thanks you men, such an idiot mistake :sweat_smile:


#148

Why am I getting this error?

JET RUNTIME HAS DETECTED UNRECOVERABLE ERROR: runtime error at com/excelsior/jet/runtime/os/ThreadStack.java:96
Unexpected OS failure: failed to retrieve stack bottom: Success (errno 0)
Please, contact the vendor of the application.
Extra information about error is saved in the “jet_err_1274.txt” file.


#149

I have to do this for school but ive no clue
can u send me a copy paste solution or something like that
[lolno]

thanks


#150

“Something like that”…
answer = “75 64 64 64 64 64 64 64 64 6b 64 6b 64 6b 6b 6a 64 6a a 2c 79 6c 6c 75 66 68 74 69 61 66 20 73 72 75 6f 59 a a 2e 6e 6f 69 74 75 6c 6f 73 20 65 74 73 61 70 20 79 70 6f 63 20 61 20 65 6d 20 64 6e 65 73 20 6f 74 20 65 6e 6f 65 6d 6f 73 20 72 6f 66 20 67 6e 69 74 69 61 77 20 6d 61 20 49 a a 2e 65 75 6c 63 20 6f 6e 20 65 76 27 49 20 74 75 62 20 73 69 68 74 20 6f 64 20 6f 74 20 65 76 61 68 20 49 a a 2c 6d 61 64 61 4d 2f 72 69 53 20 72 61 65 44”
print("".join([chr(int(x, 16)) for x in answer.split()])[::-1])


#151

Very poorly phrased problem. Please somebody help me understand what the program actually wants.
I’m storing the nodes in a 2D array (Java) like this: -

0 0 . 0 . 0 //First Row
. 0 . 0 . 0 //Second Row

and so on. Please help me understand what does it want? Do I need to scan the entire row to the right of the current element to find the zero, while skipping the dots(.)

Thanks


#152

Yes. You need to find the next zero to the right and next zero downwards for every zero.


#153

i have trouble with my logic.

i use java, and use linked list algorithm for node class, and use a pointer to reference next object. in some test cases the node have a gap that defined in input with a dot char, right now i don’t get how do i defined the gap, while following the requirement to fill the gap as the empty cell which i skipped in loop. i think this issue is important with diagonal test case.

char VALID = '0', INVALID = '.';
// Node from input
Node[] nodes = createNodes();
// the 0000. text converted to char arrays
char[][] links = inputArrangeByRow();

int incr = 0;
for (int row = 0; row < links.length; row++) {
    for (int col = 0; col < links[0].length; col++) {
        if (links[row][col] == VALID) {
            if (col + 1 < Main.CELL_WIDTH && links[row][col+1] == VALID) {
                nodes[incr].nextRight = new Node(row, col+1);
            } else nodes[incr].nextRight= Node.EMPTY;

            if (row + 1 < Main.CELL_HEIGHT && links[row+1][col] == VALID) {
                nodes[incr].nextBottom = new Node(row+1, col);
            } else nodes[incr].nextBottom = Node.EMPTY;
        } else {
            nodes[incr] = Node.EMPTY;
        }
        incr++;
    }
}

this code generate node with no problem, but the gap messes my generated node.

EDIT: mention about generating node


#154

I think you should write down your strategy before coding.

Create list of nodes from input
For each node
    Find the first node on the right
    Find the first node below.

Then, what’s your strategy to find the first node on the right?


#155

i just add row and col index.
right = (row,col+1)
bottom = (row+1,col)