There is no Spoon - Episode 1 puzzle discussion

I re ran the tests until they passed :stuck_out_tongue:

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.

Perhaps… But once again, my clojure script get 100% not matter how many time I run it…

Indeed, i am surprised that i am the only one that gets this problem.
Anyway i’m done here.
Have a good day :smiley:

Thumbs up, good puzzle.

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

You are right, your code is probably bugged… Can I see it ?

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();

        }

    }

}

The assignment is very simple… i don’t see the problem with code, and i’m not a beginner

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 added that because of this error:

### Game information:

invalid input. Expected 'x1 y1 x2 y2 x3 y3' but found '1 0'

I now get the same error again…

You need to provide the coordinates of the node, the next on the right and the next under.
It’s 3 pairs altogether.

ok thanks, i got it now…

No Idea what is wrong with my output;
Second testcase (0.0.0) my output:

0 0 2 0 -1 -1

2 0 4 0 -1 -1

4 0 -1 -1 -1 -1

This should be correct?

Your solution seems ok, maybe you have a formatting problem.

What is your error message ?
Are there any spaces at the end of your lines, or do you add empty line at the end ?

lol the description mentions loops twice… then under learning opportunities it only shows lists… lol…

Hello! When I use System.err.println … my code gives all answers.
When I type System.out.println - it gives only the first answer.

What could be a problem?
Thank you

This was a really challenging puzzle for me in Java rated as beginner level. Struggled a full day with this one, but then got it right!

I’m stuck … On the horizontal example it look that we have 0.0.0 and I get
(-1, -1) is not to the right of (0, 0). Expected (2, 0).
image

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

for
0 . 0
. . .
0 . .
right neighbor of 0,0 node is 2, 0 and bottom neighbor is 0, 2
can that help you solve the puzzle?

2 Likes