6 kyu
Maze Runner
284 of 7,768adrian.eyre
Loading description...
Arrays
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
I liked this kata too much because it makes You to think hard in every marshroot case. Thank You very much!
Simple funny kata)
I don`t clear understand the 6th rule: "6. If you find yourself still in the maze after using all the moves, you should return Lost.". What is the maximum count of moves that is limited?
Whenever you have no moves left in the "directions" array, that's the limit 👍
Great kata! I think this would be a good introduction to nested lists/arrays.
This comment has been hidden.
This comment has been hidden.
Thanks!
Great kata thank you I learned a lot!
I am pretty sure my code was/is correct: However I am facing the followingn :
File "/workspace/default/tests.py", line 24 test.assert_equals(maze_runner(maze,["N","N","N","N","N","E","E","S","S","S","S","S","S"]), "Dead") ^ IndentationError: unindent does not match any outer indentation level
It looks like you edited the sample tests (by accident?). Click "Reset" to fix them, and make sure to copy your solution code before you do.
yes that fixed the issue thanks
solution wont work when it is correct
If you think that the tests are incorrect, then you need to show proof. Please do not open issues on kata just because you think your solution must be perfect, especially when you do not provide any other kind of context or information.
Got this kata done in Python after debugging alot, its a easy-ish 5 kyu and a more challenging 6 kyu difficulty in my opinion.
cool kata
Tests are horrible. Debugging is near impossible with random tests. On top of that, sometimes just adding console.log() will all of sudden pass random tests.
All of the basic tests done, but i got this when trying to attempt: "Should return Lost: expected undefined to equal 'Lost'" and I can't see test parameters unfortunately:( Could you help me with that? lang: js
Had a lot of fun with this one; thank you!
Wow, amazing. I love this kata.
Very good kata. :D
I don't understand where the start and finish points are stated?
What do you asking exactly? Some detail please?
The start point is 2 , and the finish point is 3.
Katas description is telling everything. Can you read the description please?
Java translation
Approved by someone
man oh man. this one had me sweatin for hours
Is this kata going to be translated to Go? Would like to try to solve it!
You may do the honors. Also, once you're done, you can ping any Power Users here for a review, though the time required for such process to commence is not guaranteed.
Sadly had to check solutions and do not understand what I did wrong (fixed tests passed, randoms did not).
It is extremely annoying, however, when tests that pass aren't being displayed and the ones that don't provide no information beyond "(actual) expected to be (expected)".
You can view the tests, on any kata, by printing the inputs to console/stdout:
Learn how to do this by reading here:
https://docs.codewars.com/training/troubleshooting/#error-messages-and-printing-your-inputoutput
Basically you just insert a "print(name_of_input)" somewhere in your code - or whatever the equivalent console display command in your language is.
Exactly the same, good kata but poor tests
< Deleted >
Lua translation
Thank you
.
This comment has been hidden.
The maze has two dimensions...
You must check whether
i
is out of bound before doingmaze[i][j]
, since an out of boundmaze[i]
will yieldundefined
and it is not accessible via indexing.Had a lot of fun on this one, thank you for the great kata, adrian.eyre
needlessly annoying.One doesn't need to find starting position in a maze.
All example test cases are passing but some random test cases (5-8) are failing not able to understand what am i doing wrong
OP solved it, closing
Amazing Kata, one of the best that I did so far!
Enjoyed it a lot. Thank you adrian.eyre
I am getting this error, and I am almost sure this is not my bad, any ideas?
Hi,
not an issue. Issues are for problems in the code of the kata. Here, your code is using invalid syntax => that's a "Question".
about that problem of yours: when used,
def
has to be at the very beginning of the line (according to the current indentation level)Cheers
Hi, my
def
is in fact at the very beginning of the line, I've marked this as an issue, beacouse I think there is a problem withtest.py
test file, not my solution, and not something I could change.no, you should look up how to define a function in python again: there is absolutely no way, that your
def
is at the beginning of the line when you havemaze =
just in front of it... ;)This comment has been hidden.
You can't assign function to a variable, you can call a function and store its return to a vaiable but not declare the function in the variable it self.
You actually can assign a function to variable https://www.geeksforgeeks.org/assign-function-to-a-variable-in-python/ , however you can't assign a function DEFINITION to variable. But once again im saying this is not my code where the error occurs, error lies in the test cases.
This is a fantastic problem. Enjoyed solving this :D
This comment has been hidden.
A problem with your code is not a kata issue. Hopefully this may help: Troubleshooting Your Solution.
The error is very likely coming from:
maze[verticalPos][horizontalPos]
: you're attempting to accessmaze[x][3]
, wherex
is out of bounds.Fun challenge, but significantly harder than any other 6 kata I've attempted. I'd consider this a 5 for sure.
Hello! I use Python3. I have a problem with the Python interpreter "Eror102". Thinks!
i think this is too hard for 6 kata.. xD I don't even know where to begin with.
This comment has been hidden.
Hi, I'd recommend you first identify which test is failing, then comment out the other tests and add
puts
statements at different points to help you to understand what is happening in that test scenario. Hopefully, you should then be able to see what the issue is.I started learning JavaScript about 3 months ago, trying to make my way into web development. Have been using CodeWars recently as a practice to make sure I'm understanding what I'm learning. This one was a very fun problem. It took me a little to wrap my head around, and I'm sure my solution is far from perfect; but, I'd like to say that this has really helped me build some confidence! Thanks.
I get this error: TypeError: Cannot read property '3' of undefined I'm in javascript but I compiled the problem in many editors and only this one gives me this problem? how can I fix? Thanks
This comment has been hidden.
This comment has been hidden.
Hi Gabri, what did the comment say? I am running into the same issue as you where the code runs successfully in other editors.
Hi, I'm passing all the tests but then failing on the attempt. Unfortunately the feedback only tells me that I'm failing. How can I see the maze & directions to check out where I must be going wrong. Thanks in advance.
Never mind, I found my error! Passed...only 2 points though! XD
First kata I have encounterd that does not make sense to me. How do you navigate the maze(2D arrays) with the directions???????? I'm so disappointed in myself that I cannot figure this kata out.
This comment has been hidden.
Maybe I'm mis-reading the instructions, but to me it's not clear whether I am supposed to write something that actually navigates the maze, or whether I'm supposed to write something that returns the right result when someone else tries to navigate it, or what... Afraid I'm quitting this one as I agree that it just doesn't make sense. Might be me though
I started codewars about a week ago and this is without question one of the more creative, well explained kata I've done. Will be doing others by you as well. Thank you
This comment has been hidden.
OP solved it, closing
Great challenge that visualizes the algorithmic problem.
This comment has been hidden.
Hi Neil. I would very much doubt its in the test cases as 1,265 warriors have solved this kata in Pyhton 😊
I can't see anything obvious that stands up, sorry.
Seems to me you don't check the wall collisions
This comment has been hidden.
OP solved it, closing
This comment has been hidden.
The second int of the variable
me
is always-1
This comment has been hidden.
This comment has been hidden.
Not sure why you are
maze[array][sub_a] + 2 != 2
why notmaze[array][sub_a] == 1
?This comment has been hidden.
Hi, just curious, but what exactly is the
undefined
object for which the property3
cannot be read? (because this produces the error) I have not done this kata in JS, but it seems like you're trying to find the number 3 in something that can't or doesn't contain the numebr 3 . . . could that be the case?Hi there. Your code is not checking if the move is out of bounds of the maze
I've the same problem :(
I have the same issue (JavaScript), all my tests pass and I'm checking if the move is out of bounds.
yea it definitely has to do with that.
@matrixersp you're checking out of bounds on the array :-)
maze[start[0]][start[1]] === 1
where eitherstart[0]
orstart[1]
is < 0 or > maze lengthThis comment has been hidden.
Hey, it's a bit hard to understand the code and it's in poor format (check this link). But I managed to change the last few lines to make it work. Your check for Finish isn't always correct.
You can try to use
console.log()
at beginning of function to see the maze, directions and read the error messages below to see which one failed.More info about troubleshooting your solution HERE. Good luck!
Thank you very much for your response! I will read! Thanks you!
Hello,
This kata in Python has issues in test cases.
Maze equals:
test.assert_equals(maze_runner(maze,["N","N","N","N","N","E","E","E","E","E","W","W"]), "Finish") while that test case should be "Lost".
Also other test cases show "Finish" instead "Dead".
Kindly ask the author to check.
Thank you!
Hi there. I have answered this question several times, please see below comments.
very fun kata! helped me to improve my debugging skills in CW:D
This comment has been hidden.
C Translation available. Please scrutinize for approval, thanks!
Hi @rowcased thank you for the translation. It wont let me approve it, I think its because I've updated the description. I know its a pain but would you mind redoing the translation please?
Hi adrian.eyre, sure! here's a fork
Thanks for doing that and thank you for the translation :-)
You're welcome, thanks for all the great kata!
Very challenging kata
I'm so frustrated with this Kata. Thought it was easy at first but then found out some tricky situations. But even after fixing them, whenever I click the "Attemp" button, the number of Passed and Failed cases kept changing. Like there're time they're 74 - 36, 72 - 38, 70 - 40, 80 - 30....
hi,
not an issue, just your code that is incorrect: those tests are called random tests for a reason... ;)
print the inputs, then debug your code.
cheers
Thanks man! I've already knew why I'm wrong in some cases.
This was a really cool one (challenging for me in a good way as a beginner)...thanks!
So many wrong test cases, they made me feel so annoyed when I had to check again so many times and found that it is the problem of test cases.
Could you be more specific? If test cases were wrong, there would be many issues open, but there aren't.
What language are you using? Which input fails? And what do you think it should return?
This comment has been hidden.
the test case is wrong, I tried by my hand and found it wrong
In this kata, you don't need to use up all directions. In the third test case, you can get to the finish point by
("N","N","N","N","N","E","E","E","E","E")
moves. Then the expected answer is "Finish".This is very sweet, love it
Loved this kata. Lots of fun. It would be nice to have in the description that if the player leaves the confines of the maze, that the function should return 'Dead'.
Thank you, I'm glad you enjoyed this kata.
The description already lets you know "If you hit any walls or go outside the maze border, you should return Dead."
This comment has been hidden.
same :)
what's the starting point?
And it is where you start and follow the directions.
For JavaScript there seems to be a mistake. I fail test, where maze looks like this:
[1,1,1,1,1,1,1,1,0,1, 1,3,1,0,1,0,0,0,0,1, 1,0,1,0,0,0,1,1,0,1, 1,0,1,1,1,1,1,0,0,1, 1,0,1,0,0,0,0,0,0,1, 1,0,1,0,1,0,1,0,0,1, 1,0,1,0,1,0,0,0,0,0, 1,0,1,0,1,0,1,1,0,1, 1,0,0,0,1,0,0,0,0,1, 1,1,1,0,1,1,1,1,2,1]
The directions are simply = [N, E, E]
As you can see it should return "Dead" as I bump into the wall (and I try to return it), but this test tells me that it expects "Lost". What on earth?
Are you sure they are the correct maze and directions input or the result Lost? Is this a static or random test? If its the static test then the maze is
And should return
Dead
It's just that 576 people have solved it in Javascript and they haven't raised an issue :-)
I'm sorry, you're right. Absent-mindedly I looked at info about the random test above the one I described. Everything's fine. Once again sorry.
When call the log the return value I get 'Finish' but I still get the error: "Should return Finish - Expected: "Finish", instead got: nil". The last line of my code is returning 'Finish' not nil
Wow I loved this kata.
I think some test are wrong, for example: maze = [ [ 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1 ], [ 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1 ], [ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1 ], [ 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1 ], [ 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0 ], [ 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1 ], [ 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1 ], [ 1, 1, 0, 1, 2, 1, 1, 0, 1, 1, 1, 1, 1, 1 ], [ 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1 ], [ 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1 ], [ 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 3, 1 ], [ 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1 ], [ 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0 ] ];
var directions = [ 'W', 'E', 'S', 'N', 'S', 'S', 'W', 'S', 'S', 'S', 'N', 'E', 'N', 'W', 'S', 'N', 'E', 'W', 'E', 'N', 'W', 'S', 'E', 'S', 'W', 'S', 'E', 'N', 'E', 'N', 'E', 'E' ];
After the first move you are Dead, instead it expects that you are lost
Im assuming you have raised this for the Javascript translation. Are you sure you are outputting the correct data. 517 people have solved this kata in Javascript :-)
You are rigth!, that was the log of the previous test! Sorry for that! Now, 518 people have solved it :)
I keep catching a random number of errors between 5 and 15. The error messages don't present much of a pattern to work on. Is there any way to see input for debugging purposes?
Same thing is happening with me too. Even if I pass all the tests there is a Exit Code error stating that the variable(throws different variable in every run I perform) was referenced before declaration.
I checked the code in Jupyter notebook; works smoothly without any error.
This comment has been hidden.
Pass all tests but shows error:
TypeError: Cannot read property '3' of undefined at mazeRunner at /home/codewarrior/index.js:67:19 at /home/codewarrior/index.js:135:5 at Object.handleError
that's in your code, not in the test suite, meaning that's your code that is incorrect. Don't forget that the sample tests are just what they are: "sample".
Same Issue. I've tested multiple times with no mention of any "3" in my code.
Please evaluate out of bounds of the maze in your code.
My first attempt passed 149/150. I reloaded the page, attempted again, passed all. Is this a thing?
There are several random tests that the first time you submitted didn't pick up an error in your code but the second time the random tests may have missed it. If anything its a problem with my tests not testing all edge cases, which I will look into :-)
okidok, thanks. so I guess I should retry sometime again, to make sure my code works definitely.
Log:
Maze: [[1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 3, 1, 0, 1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1, 1, 1, 2, 1]] Directions: ["N", "W", "W", "W", "N", "N", "N", "N", "W", "W", "S", "S", "S", "S", "W", "W", "N", "N", "N", "N", "N", "N", "N", "S", "S"]
Should return Finish - Expected: "Finish", instead got: "Lost"
This is the log I got when i attempted. I think this testcase is incorrect.
Without looking too deeply into this please could I refer you to the line in the instuctions.
If you reach the end point before all your moves have gone, you should return Finish.
Hope this helps :-)
Yes I know. The end point for finish is 3. But if you follow the Directions given above, its not reaching 3.
Though it perfectly does reach the exit point...
Ok got it.
Uuuuurgh my solution is so messy!
Very fun kata!
I like this kata, since it's easy enough so solve quickly and at the same time hard enough to invite creating a class or two and then let the objects 'talk' to each other.
love this kata! interesting:)
I love Maze Runner Movie! Thank you for the nice Kata.
This comment has been hidden.
Hi there. Which language are you getting this error with?
Hi! I'm using Javascript.
Hi @BusyReadingSomething, would you mind pasting your code here please (set the "Spoiler" flag) so I can test. I've looked at the test code and cant see anything wrong with that plus 200 people have solved it in Javascript :-)
I finished this Kata succesfully (C#), but didn't take into account the rule that if you reach finish before the end of moves you should return "Finish". I had 1 test failing from the local ones, but the non visible tests apparently don't test this condition, so I could finalize it..
Thanks for letting me know, test cases now updated :-)
This comment has been hidden.
Please refer to the instructions
If you reach the end point before all your moves have gone, you should return Finish. If you hit any walls or go outside the maze border, you should return Dead. If you find yourself still in the maze after using all the moves, you should return Lost.
You are still looping after you are dead, are you not?
This comment has been hidden.
Hi @RobertRappole, I've just debugged your code and it seems to produce an error on line 16
Hope this helps.
I had the same error, but i solved it by using try{}catch{}
My Python code is passing the sample tests but randomly fails at different real tests. The system complains that I am showing either 'Finish' or 'Lost' instead of 'Dead'. Is there any way I can look into the test cases to see whats going on?
Hi @Stephard, you could try
print(maze)
to display the maze andprint(directions)
to print the directions to the standard output.Thanks a lot :)
This comment has been hidden.
Hi @OscarAlvarez, I've checked the Javascript tests and that particular test is
Test.expect(mazeRunner(maze,["N","E","E"])=="Dead", "Should return Dead")
maybe I have the expected and actual the wrong way around. Please check your code to make sure it's not outputing "Lost".The test before it
Test.expect(mazeRunner(maze,["N","N","N","N","N","N","N","N","N","S","S","S","S","S","S","S","S","S"])=="Lost", "Should return Lost")
is expecting "Lost". You're not mixing it up with that are you?For Ruby, I'm passing every single random test and all but one test case. For the last test case (non-random) I get:
Should return Finish - Expected: "Finish", instead got: "Lost"
Are you sure this isn't a typo?
I noticed on the first round of test cases, the third test case should be "Lost", but it instead wants "Finish".
Test.assert_equals(maze_runner(maze,["N","N","N","N","N","E","E","E","E","E","W","W"]), "Finish")
But that's impossible for it to be 'Finish' when the finish line is on the very 'east' side of the maze! Please correct both the sample test case and the final test case when clicking submit.
Hi @john129er. Sorry for the confusion, I've updated the description to make it more clear. The start and the finish positions will change for the final tests.
I know that much already. My code accounts for a random starting and ending location, not fixed locations. Here's the issue. For this maze:
The answer to this line:
should be "Lost", not "Finish". This is one of the test cases when I push the "RUN EXAMPLES" button. But because I can see the test case, I can fix your bug so my code will run correctly.
However, when I hit the "ATTEMPT" button, I pass all the random tests (with random sized grids and random start/end locations). But there is one non-random test that I get this output from:
Should return Finish - Expected: "Finish", instead got: "Lost"
It's the seventh test case, just before the program is run through a bunch of random test cases.
I'm wondering if, like in the test case I have above, this other test case should be fixed also. I can't see the test cases after pressing the "ATTEMPT" button so I can't verify that it really is an error. I just find it highly suspicious that I can pass every other test, including random tests with random start and end points, but I can't pass that one.
I'm asking you to review all the test cases to make sure that you didn't accidently put the wrong outcome.
Does that make sense?
Hi @john129er. Please refer to the descriptopn
If you reach the end point before all your moves have gone, you should return Finish
Hope this helps.
Yes, I see where my mistake was. Thanks for your patience. I'm fairly dense most days and this just goes to show it. Passed all tests. Thank you.
Not a problem, hope you enjoyed :-)
Hi,
I think you should rewrite the part of the description about the size of the maze :
"The Maze array will always be square i.e. N x N but its size and content will alter from test to test." instead of "7 x 7". It would be more "accurate".
Cheers,
B4B
Fair comment, I've updated the description. Thank you :-)
Can somebody explain me how's that possible http://joxi.net/EA4KL0jIQpo02b ? How come 'Lost' is expected there ? Found another interesting test case arr : [ [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 ], [ 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0 ], [ 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 1, 1,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[ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0 ], [ 2, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0 ], [ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0 ], [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0 ] ];
directions : ['E','S','N','E','W','N','N','W','W','S','N','W','E','E','S','W','W','E','N','N','N','S','S','E','E','W','S','E','W','E','W','N','W','S','E','E','W','E','N' ]
expected result 'Lost'. Wtf ?
You're reading the test results wrongly. In the screenshot you passed that test but you failed the one above it. Think about it the order of the test results logically - you print the input first, then you return the value which means it checks for equality, resulting it saying "You Passed".
Thanks a lot for your help dude ) finally solved that.
Nice one :-), why not try Mastermind https://www.codewars.com/kata/mastermind and help it get out of beta by ranking it once complete :-)
The use of short or obvious variable names in the Kata Test Cases in Python increases the chance of problems due to collisions with user solutions' choices for their variable names, and it's difficult to debug when this happens. Please try to use as few global variables as possible, and use long, non-obvious variable names and/or store them inside of a single variable or object.
Fair comment.
This comment has been hidden.
Cool, nice one :-), thanks for solving.
Thanks for making it! It was a good challenge :)
Out of interest, I'm quite new and I'm not sure how I can translate Katas. Do you know at all?
Once you've solved a kata you can click on the
language drop down menu
from theDetails Page
and select+ Add New
. This should open the kata for editing. Once complete the Kata Sensei can approve/reject the translations. Hope this helps :-)Ah, thanks!
This comment has been hidden.
@Edwuards1327
,You need brackets after
if(el.indexOf(2) != -1)
because it's more than one line.This line causes your other error:
var current = maze[vertical][horizontal];
One way to fix it is to catch the error and return 'Dead' if it comes up. I mostly write Python so this may not be the proper way to handle this in JS (but it works).
With those two minor changes, your solution passes.
Hopefully that helps!
Thanks for this reply @zebulan, hope it helps @Edwuards1327
@adrian.eyre
,Python 2 isn't available.
Hi there, yeah sorry, Python isn't my strongest language so I made a translation for version 3.
If you want to translate, please feel free to submit a version. :-)
I enjoyed this kata and I think I solved it, but one of the Test cases is returns nil instead of lost, and it's kinda weird since it passes every Random Test.
Same here:( That is the only fail I have :(
Hi Animoni. Which language? please provide more info on the test case. :-)
This comment has been hidden.
Hi @animoni, it looks like your code is return
nil
but not sure why without looking at it :-) if you want you could post your code here and mark as spoiler and I can try and solve it :-)The final test cases (in every language) are below then lots of random tests.
This comment has been hidden.
Cool, nice one :-)
Hi Adrian, Thanks for the interesting kata!
You wrote to Animoni that the maze 2 replies above and the following directions should return 'Lost': Test.assert_equals(maze_runner(maze,["N","N","N","E"]), "Lost", "Should return Lost")
I totally agree, but when I attempt to test it, I am getting this error: "Expected outcome to be Dead: expected 'Lost' to equal 'Dead'". How could the expected answer be 'Dead'?
Thanks.
Hello
Adrian
here's a PHP translation(I've put less walls[1's] in random testing so it's a bit more balanced outcome between 'Dead','Lost' and 'Finish', hope you don't mind).Thank you so much for translating :-), please feel free to translate any of my other katas.
I'd like to suggest you change this part "The Maze array will always be square ie 7 x 7 but will alter from test to test." to something like this "The Maze array will always be square i.e. 7 x 7 but its size and content will alter from test to test.". I only discovered that the size changes when I opened discuss section. However, great kata anyway.
Fair comment :-), i've updated the details. Thanks for solving.
Hi, I'm enjoying this kata, however, I'm confused by one of the specs. I'm passing 49 tests and failing the first one which is:
N N N W W W N N W W S S S S W W N N N N N N N N N N W
✘ Should return Finish - Expected: "Finish", instead got: "Dead"
Those directions do not lead to the finish...Thanks!!
Never mind....I see that the maze size changes. I thought it was always 7x7.
Thank you for solving. Please could you grade this kate if you havent already :-)