But i ran some tests locally with time checks.
Here is the code FYI.
Here is the report 50 runs, with a grid 8x8:
(unit here is milliseconds)
From START to STOP ->Average value : 1318.04
---Details---
From START to INIT ->Average value : 1275.82
From INIT to PARSED ->Average value : 1.32
From PARSED to BUILDED ->Average value : 0.6
From BUILDED to ENDED ->Average value : 15.36
From ENDED to STOP ->Average value : 24.94
The START is echoed before executing the program.
The INIT is the first thing the program outputs.
The PARSED is printed after the grid is parsed.
The BUILDED is printed after all the outputs strings are built.
The ENDED is printed after the strings are printed, it is the last action of the program.
The STOP is echoed after the program ran.
Observation:
The stage that consumes the most time is the initializing of the JVM/Clojure jar loading.
The Clojure script time consumption seems reasonable (but not fully optimized by design maybe)
Hypothesis:
Maybe when the server is loaded, the start of the JVM might take too much time and the the timeout occurs before the program is really running.
Conclusion:
The Clojure script does not seem to be the cause of the underlying problem at the very least.
I’d suggest striking lists from the learning opportunities and adding arrays, loops, & string manipulation. I’m actually kinda at a loss trying to imagine how you’d tackle this with lists. By the time you’ve walked over the map to make a list of nodes you’ve already solved the puzzle. Wait, was that the idea? Have I been Miyagi’d?
Its bugged. In local IDE i am having no trouble but here i am getting all kinds of errors.
Game information:
Timeout: the program did not provide 1 input lines in due time…
I just parse the input in a 2D array and print a debug line before doing anything, but obviously it takes too long, so it doesn’t even reach the debug line. I am coding in java
I tried using 2D array, now i changed it to go thorugh list of strings (lines)… I am telling you, in my local IDE, everything is working, and working fast. My code bellow:
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int width = in.nextInt(); // the number of cells on the X axis
int height = in.nextInt(); // the number of cells on the Y axis
if (in.hasNextLine()) {
in.nextLine();
}
List<String> lines = new ArrayList<>();
for (int i = 0; i < height; i++) {
String line = in.nextLine(); // width characters, each either 0 or .
lines.add(line);
}
if (in.hasNextLine()) {
String s = in.nextLine();
System.err.println(s);
}
in.close();
for (int y = 0; y < lines.size(); y++) {
String line = lines.get(y);
for (int x = 0; x < width; x++) {
if (line.charAt(x) == '.')
continue;
System.out.print(x + " " + y);
int neighbourX = -1;
int neighbourY = -1;
int position = x;
while (++position < width) {
if (lines.get(y).charAt(position) != '.') {
neighbourX = position;
neighbourY = y;
break;
}
}
if (neighbourX != -1 && neighbourY != -1)
System.out.print(" " + neighbourX + " " + neighbourY);
neighbourX = -1;
neighbourY = -1;
position = y;
while (++position < height) {
if (lines.get(position).charAt(x) != '.') {
neighbourX = x;
neighbourY = position;
break;
}
}
if (neighbourX != -1 && neighbourY != -1)
System.out.print(" " + neighbourX + " " + neighbourY);
System.out.println();
}
}
}
Remove this piece of code, and you won’t timeout anymore.
You’re trying to read on the input although you read everything there was to read. Our system considers you finished your first turn and you didn’t return anything yet so it timeouts.
I thought while reading instructions that we should the next right and below, no matter if empty or not …
but you’re looking for the next no empty …
I’m stuck, with what I understand, maybe you’re right