[Community Puzzle] Dungeons and Maps

@Di_Masta
Enjoyable puzzle with a well-written intro, thank you.

Test cases seem incomplete, though.

For example I would expect inputs that lead into infinite loops, which do not contain the origin of the search.
Minimum testcase (TRAP):

3 2
0 0
1
>>v
T^<

Hi, thanks for the feedback I think the 5th test case Di is a such scenario with loop.

I did my coding in pycharm, and each test case gave the correct answer. When I pasted it into the site, it gave a wrong answer to three test cases. No errors. Iā€™m stumped.

What does the console show?

Also see if youā€™ve swapped the row and column inputs, youā€™re given first the row then the column start index.

Okay, I goofed. I managed to include all the maps into each grid N times, instead of a separate map in each grid N times. I love how something so simple can throw it all off. Asking me to check the row and column inputs got me looking at it. Thank you.

I loved the puzzle. It was a lot of fun.

1 Like

The infinite Loop on your nameā€¦ I donā€™t like you XD
Awesome puzzle anyway :wink:

1 Like

The instructions do not explain what to do with an empty square ("."). A reasonable interpretation is that the player can move in any direction from an empty square, whereas they can only move in one direction from a square containing an arrow. This makes the problem more interesting, requiring a flooding algorithm. I solved it this way and was disappointed to find that an empty square is treated exactly like a wall. At a minimum, please make the instructions more clear.

Hi, the idea is that you start on a square with an arrow and you must follow the arrows to arrive save/alive to the treasure. The empty squares may be filled with nasty surprises.

I donā€™t really get the rules of what makes a map valid or not. I was able to do points 1-5 with the following rules:

  • Least number of steps

  • End position equal to the treasure

  • That there is a way in the map, so basically that not all boarders are made by ā€œ#ā€

Could anyone give me a clue regarding this.

@Di_Masta

Hi @NAK95,

If the path of the arrows (><^v) doesnā€™t lead you to a treasure cell, mark with ā€œTā€ the path is invalid which means that this map will lead you to a ā€œTRAPā€.

Does that help you?

1 Like

Hello, I have a problem reading the data.
For all the tests, itā€™s OK and ā€˜Successā€™ but for the ā€˜Diā€™, I have this error :slight_smile:


Erreurs

Exception in thread "main" java.util.NoSuchElementException: No line found

at java.base/java.util.Scanner.nextLine on line 1651
at Solution.main on line 34
Sortie standard :

COLONNES : 19
LIGNES : 12
startLigne : 2
startColonne : 4
N : 2
m : 0 | l : 0
m : 0 | l : 1
m : 0 | l : 2
m : 0 | l : 3
m : 0 | l : 4
m : 0 | l : 5
m : 0 | l : 6
m : 0 | l : 7
m : 0 | l : 8
m : 0 | l : 9
m : 0 | l : 10
m : 0 | l : 11
m : 0 | l : 12
m : 0 | l : 13
m : 0 | l : 14
m : 0 | l : 15
m : 0 | l : 16
m : 0 | l : 17
m : 0 | l : 18
carte : 0 OK
m : 1 | l : 0
m : 1 | l : 1
m : 1 | l : 2
m : 1 | l : 3
m : 1 | l : 4
m : 1 | l : 5

Ɖchec
TrouvƩ :

Rien


Here is the code for the reading part, with comments

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        COLONNES = in.nextInt();
        LIGNES = in.nextInt();
        int startLigne = in.nextInt();
        int startCol = in.nextInt();
        int N = in.nextInt();

        System.err.println("COLONNES : " + COLONNES);
        System.err.println("LIGNES : " + LIGNES);
        System.err.println("startLigne : " + startLigne);
        System.err.println("startColonne : " + startCol);
        System.err.println("N : " + N);

        String[][] maps = new String[N][COLONNES];
        if (in.hasNextLine()) {
            in.nextLine();
        }
        for (int m = 0; m < N; m++) {
            for (int l = 0; l < COLONNES; l++) {
                System.err.println("m : " + m + " | l : " + l);
                maps[m][l] = in.nextLine();
            }
            System.err.println("carte : " + m + " OK");
        }

For all the others tests, no problem, but for it, it block at line 6 of map 1.

Do you have any idea ?
Thanks

I tried to read in PHP, no problems :frowning:

Should the line near the end be:

for (int l = 0; l < LIGNES; l++) {

instead?

You are right, thanks :wink:
Stupid error, lihe most of them :slight_smile:

Interesting parsing problem, I thought I had it figured out then I kept go around and around till I timed out - and then I ended up over-running the edge of the boundary :slight_smile: Thanks for making this!

Hey, Iā€™m having trouble near the end. My code works on all test cases except for the hidden ā€œ2 mapsā€ one. Since I canā€™t see the failure, Iā€™m having trouble figuring out how to fix it. Is there something different about this example specifically, or is my code just messing up in a weird spot?

Probably messing up in a weird spot, as the ā€œ2 mapsā€ validator is very similar to the ā€œ2 mapsā€ test.