Hi, I don’t know if this is the proper place to ask for tips or what, but I’ll try anyway
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
What am I missing?
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.
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
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”
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…
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.
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
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.
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(.)
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.