Hey.
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.
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
2
.>>>>v
.^...v
.^<.T<
......
......
......
..>>T.
......
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
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.
Thanks.
The top left of the map is 0,0. For the example maps, the given starting position is 1,1.
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.
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.
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â
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