[Community Puzzle] Dungeons and Maps

The cells indexing starts from zero.


Thx a lot for your help

Hello, could somebody please update the description for these 2 point:

  • What does ‘Empty square’ do? (I read a few first cmts but didn’t see any answer)
  • Why case 1 and case 2 should be valid? (I read @anon72424297 and found the answer, the description forgot to add map indexing should start from zero.)

I’m honest that I was a little bit panic at first because I don’t understand the sample output. I think if the description have more info for the 2 points about then it’ll be easier for everyone to understand.

P/M: Does anyone have raw input of 3 last testcase? I tried to log (console.error) them out but it doesn’t work. The console always breaks them like this:

    '.', '#', '#', '#',
    '#', '#', '#', '#',
    '#', '#', '.'
    '.', '.', '.', '.',
    '.', '.', '.', '.',
    '.', '.', '.'
    '.', '.', '.', '.',
    '.', '.', '.', '.',

That’s because you’re printing an array directly, the default behavior in that case is what you see.
If you want a different output format you need code for it. Here’s an example :

dungeonMap.forEach(row => console.error(row.join('')));

Join creates a string from the array elements, and inserts a character between them (’’ here). Doing that for each row of a dungeon map will print it in the console.


I guess that’s one of solutions. But don’t you think print a whole array out look much better?

An array is an object and has a default toString implementation, this is part of the language specification : https://tc39.es/ecma262/#sec-object.prototype.tostring
You can create your own class and override the toString call if you want, but considering you only need a one liner to get what you want, I don’t think that’s worth it.

An interesting spin of this might force the user to use the constraint that all of the maps represent the same dungeon and attempt to fill in the missing paths with data from other maps, just a thought.

1 Like

Is there any way to get some input on the “submit” cases that I fail on? I pass all the given test cases but fail on the “2 maps” one when I submit. Pretty stumped on what’s wrong with my code since there is nothing to go on

6 4
2 2

Try something like this. Expected answer is 1.
You can run custom test cases if you have Expert mode enabled in settings.


Thank you for this puzzle, really was fun to solve :slight_smile:


Hi, I’m really struggling understanding the logic here.
It says that maps 0 and 1 are okay, but not the third (in the problem description)
The first one starts on an empty square so I guessed that when starting on an empty square you can go to any valid character (><v^) around.
The second one has no valid character around so I guessed that when on an empty square you can go in any valid character or empty square.
The third one says it is not possible but by looking at the previous logic, it should be (the path is broken at some point, but if that’s the reason it is not possible, map 1 should not be correct since there is no full path from (0,0) to T

I’d be glad if someone could explain that to me.


The top left of the map is 0,0. For the example maps, the given starting position is 1,1.

1 Like

Oh thank you (I figured it out minutes later).
I found that was a bit confusing, I was thinking that the first row was actually X = 0.
Using StartRow and StartCol instead of X and Y had me lost I guess

Do you see the description of the input has this:
startRow = 1 startCol = 1

(0,0) is at the top-left corner.

I want a T on the starting position.
I think my code handle that, but I’m curious how many others it would break. :smiling_imp:

1 Like

Continuing the discussion from [Community Puzzle] Dungeons and Maps:

@Di_Masta hello, thank you for your puzzle.

To solve it, I used a simple Map class that solve it by following the path (I can add details but don’t want to spoil). All test cases passes, but when I submitting it, the validation case “2 maps” send an error.
I’ve made a few assumptions that are not specified on the puzzle info, can you tell me if some are wrong?

// assuming the test cases won’t start on an invalid position (out of map)
// assuming no circular path
// assuming path does not send out of map (< on the left border)

Thanks again for your puzzle (and help)


Hi, thanks for the kind words.
If your solutions gives the correct length for the paths in both maps in the test for “2 maps”, 3 for the first map and 11 for the second map you should pass the validation.

1 Like

Oh. nevermind, found the error (h <=> w), crazy that all tests were OK with this huge typo. Thanks for the help, I was indeed starting on the T on test case “2 maps”

1 Like

A trap, not only ín the maps, but in the puzzle itself. Can’t say I like that, seems like an oversight in the puzzle description.

It’s intentional an empty square isn’t a right end of the path.
And Happy New Year :slight_smile:

1 Like