The Labyrinth - Puzzle discussion

The grid is something like 15 x 30, meaning that if properly done, a BFS takes close to NO time (you could do 100 BFSs per seconds if you wanted).

2 Likes

pardouin is absolutely right. You should not look for algorithm improvement but you should check the correctness of your implementation. This is why I suggested to look at Red Blob games web site for a reference implementation.

2 Likes

You guys are absolutely right. After two days, this morning. when I was thinking about algorithm in general, I realized there is a bit difference between no-cycle and with-cycle BFS. With cycle. when you put neighbor node on queue. it might already be here. This is it. With an extra “AND” clause, I passed.

Thank you guys for the quick feedback. The warmth is what draws me here.

1 Like

Hey all, check out the story I made within the error stream of my code. I had a lot of fun making it, and I hope you like it too. Follow the instructions in the comments at the top of the code. Here is how to get to my code.

Follow me (Type Wings_of_Safety in search and click follow), find my solution by going to Solve It->Results->Learn from the best coders-> then select “Language:Java” and “CodinGamers you follow” Copy my code into your IDE and run it. It will spit out a semi randomized story as Kirk searches through the maze. (Though only one storyline follows Kirk.)
Follow the instructions in the comments at the top of the code.

Anyway, let me know what you think. Also, if you have suggestions on how to make my code cleaner or more efficient let me know. I used A* and found the nearest path point that had a question mark next to it.

I finally got it. It wasnt clear to me from instructions. C is not the ultimate destination. You have to move to C first and then back to T. So the solution for first test case is 7xRIGHT 7xLEFT.


Hello all,
I have a problem, my program in C++ seemed to be too slow for the 150ms response. I tried to investigate this with the code on the picture above. For only getting inputs of R/C/A, I have a large amount of time spent… VAlues goes from 115ms to 160ms… I don’t understand

To measure your execution time you have to start the timer after the first input and to stop it before your output. Otherwise you measure also the referee’s time.

2 Likes

Thanks for the reply, it’s better :slight_smile:

1 Like

Hey so, I am confused, each turn we get as input the maze with the position of Kirk, but his location on the map doesn’t get updated every turn, I only get new infos about what I discovered, but the map itself isn’t up to date since kirk isn’t displayed on the maze at the same coordinates as his actual location?

For example in the first test, we move right but he is always shown with ‘T’ all the way on the left against the wall.
Am I suppose to update his location every turn ?

Please refer to the following extracts from the puzzle statement:

the letter T represents your starting position

Input for one game turn

Line 1: 2 integers: KR and KC. Kirk is located at row KR and column KC within the maze.

2 Likes

Solved with Bash and awk.
I built a Dijkstra algorithm to clear all the fog starting with the closest fog squares, then reaching the control room and escaping.
On a first attempt with pure Bash, the program was too slow but worked for several dozen rounds before the timeout

There is an error in the “Game information” output for turn 0, it gives “Kirk’s initial location” as (unlabeled) “column, row” instead of “row, column” like everywhere else in the documentation. This threw me off course debugging for a minute.

Not sure what you are referring to. Any screenshot?

image
Assuming (row,col) format is used consistently, moving RIGHT from (5,6) would take me to (5,7), not to (6,6). The issue being that the initial position is really (6,5), not (5,6).

Well I guess the (x,y)-format is used instead of (row,col)-format for that particular line. It’s certainly confusing.

@TwoSteps Any chance of changing that to the format like the ones below, e.g.
Kirk's initial location is (row=6, col=5)?

1 Like

It’s fixed, thank you for your feedback :wink:

image

2 Likes

Thanks for mentioning that. I had the same issue, only that one test (test 5) didn’t pass when I submitted (but it did pass in the initial validation suite).

For the new testcase 5, I followed your method of switching the map. Also updated the initial starting point of Rick. However it was still failing before it got to the real failure (so something else is still needed to mimic the mirrored map). At that point I gave up and will settle with half the points (for completing 87% of the final tests).

I hope this kind of thing doesn’t happen too often, else the ability to debug the final tests in the IDE would be really important.

If you implement the shortest path algorithm correctly and use it throughout (when you explore the unknown parts of the map, when you move to the control room, and when you return to the starting position), you should be able to pass all the test cases. There is no need to consider any mirroring of the map, as the basic algorithm should work for any map. Instead, you may try to write a code to randomly generate maps and test your current code using the random maps. I had fun doing that myself.

1 Like

Thanks for the reply!
I was curious, when I look at the ASCII Art puzzle, I don’t see the CUSTOM tab. Is something special required to get it to show up?

You have to enable EXPERT mode first. You can find it by clicking SETTINGS to the left of the puzzle statement.