5 kyu
Robby, the robot
483 of 487BattleRattle
Loading description...
Matrix
Algorithms
Graph Theory
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.
This task is very complex. I have seen that the original rank of it was 2 kyu. Looks like it requires BFS or something like that. Just really cannot grasp why admins made it as 5 kyu. Even according to modern standards, it should be blue kata.
The tests fail with the
"This is not the optimal solution"
error message if the commands-list is wrong (i.e. walking through obstacles, or not reaching the destination).I had to research on the robot character itself even attempting this kata!
This comment has been hidden.
This kata definetely needs random tests. Coverage of existing tests is really bad.
Coffeescript translation + Random tests for boards 2x2-20x20.
C++ translation of this awsome kata kumited!
https://www.codewars.com/kumite/5ab10e035084d73892000128?sel=5ab10e035084d73892000128
Would someone, please review it and eventually approve it? Thanks!
When submitting, console.log makes process terminate with this wonderful error.
It seems to be issue with Codewars runner and logger, not the Kata itself. Last test is 1000000 chars long, and printing it out does crash the runner.
This comment has been hidden.
Excellent kata !
A lot of work, and then when it comes debugging (most interesting part) you found out that there is no random tests. I have no desire for further optimization. Besides that, great kata :), thanks.
Fun kata!
I'm appalled that I had to cheat for one of the cases, where my robot went as far as possible towards the target, but that was too far, so there was a little step in the solution it generated :(
Maybe I'll fix it if I get some time later.
Woot ... awesome kata. it did my head in! Thanks!
It would be nice to have a little more feedback on what is wrong with the code rather than just displaying "This is not the optimal solution". Maybe something like "This is not the optimal solution. Try using less power to reach the target".
Request Timeout,again and again. I want to know if the request timeout is due to my code...
This comment has been hidden.
My first working solution didn't pass the final submit performance tests, but I came up with another working solution in the end. If you haven't gotten this yet since your post, I recommend looking up Dijkstra's Algorithm. Apply some of its concepts to get a solution.
Whew! That was fun. Could definitely make my code a lot less repetetive, but getting the basic functionality down is a great feeling itself!
Took me a while to realize I was getting a "This is not the optimal solution" failure because my code was referencing
Commands.LET
instead ofCommands.LEFT
in one function, resulting in anundefined
being pushed onto the returned list of commands :P"This is not the optimal solution"
I think that my solution is correct. Is it possible that the solution that is failing is due to 2 valid solutions? I don't know how to debug this any further. When I submit, the 12th test fails with "not optimal". I at first thought this was an error of O(n) problem, so I re-wrote the whole thing with higher efficiency, and I'm getting the same error. I'm now thinking that there might be more than one correct answer to a maze and I'm getting penalized for that.
I think it's not an issue of this kata, more a question and a problem of your code. Just solved it without problems - as many others too;-)...
This comment has been hidden.
"This is not the optimal solution"
Better to accept the answer and then show them the glory of an optimized solution, or change the message to reflect how an optimal solution behaves. (Your solution uses O(n^2) memory, or something)
Without more feedback my choices are to walk away from a working but non-optimal solution, or give up to have a look at the solutions to better understand what's being optimized for.
This is the first question with this kind of test validation I've encountered on this site.
The message doesn't mean that the way you produce your commands is not optimal, but rather that your command list itself is not optimal. That is, there is a shorter list of commands to the destination.
The problem description of the problem states that you need to return the shortest path:
I have really enjoyed doing this kata! :)
Thanks!
.................... .................... .................... ....###########..... ....#.........#..... ....#.#######.#..... ....#.#.......#..... ....#.#.#######..... ....#.#.#S.#........ ....#.#.##.#........ ....#.#....#........ ....#.######........ ....#............... ....###############. .................... .................... .................... .................... .................... ...................T
Im 99.99% sure my solution is good, please check for yourself, yet test says different:
rfrffrffflllffrfffffflffrrrfffffflfffffffflffffffffffffffrfffffff
never mind I'm an idiot...
Resolved
Very nice kata, but I feel like the last test case was unnecssarily evil...
This was a nice one. Thanks!
Anyone using Priority Queue to solve this kata? I think it is needed for a weighted BFS, but don't know whether there is a module that capsuled such data structure.
I get "This is not the optimal solution" message, when I try to use PQueue.
How did you use
PQueue
? Byrequire
ing any module?No 'require', it's easy to implement.
This kata deserves more attention.
Excelent kata! But, to be honest, my solution is a little bit incorrect, because it doesn't consider the direction of Robby. But somehow all test cases have been passed except one in the 'example tests' section. I suggest you add all test cases from the example section to the final section. It would probably make my solution incorrect, but you should know about that issue :)
This comment has been hidden.
To avoid solutions based on reverse engineering the test cases, you could add some random testing with random fields. Here is a proposal to generate simple random fields :
you can adjust the wall density using the modulo. You could generate a list of pre-solved random fields for which a single solution is possible, and randomly pick some from the list. If I'm not mistaken, my solution generates all possible paths in case you need it. Otherwise, nice kata !
Running through the kata I've completed. Decided to rank and mark this one ready.
I am having problems with my solution timing out. How optimized do you expect solutions to be? I think it would be helpful to give some indication of the maximum size field that Robby will be playing on.
There is one test case with a 1000 x 1000 field. But maybe you can find a shortcut, where you don't have to visit each single cell in order to know the result.
The problem ended up being my debug code that displayed the map. I felt dumb after taking lots of time to add in optimization after optimization and then thought to turn off the debug code. Anyways, in the end I got a pretty good algorithm.
haha, great ;)
I was having the same problem, turned out I was computing the width and height of the map using Math.round and Math.sqrt every time I looked up a square...
This comment has been hidden.
I'm a bit confused as to why the target in the first example is "behind" the start point. Forward is really backward in this case isn't it?
The first example represents a 2x2 field ("T" and "." in the first row and "S" and "." in the second row). The start point (S) is under the target point (T). The start direction is always north. So there is one step (move forward) to do in order to reach the target.