5 kyu
Optimized Pathfinding Algorithm
23 of 143ByteSheep
Loading description...
Games
Algorithms
Puzzles
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.
Hi, I'm trying to resolve this in Javascript, whenever I try submiting, Random test and Performance testing fail.
If i remove all the walls from the Grid, the performance test passes.
anyone knows why this is ?
This comment has been hidden.
Thanks, I've updated the test cases as suggested!
My solution on C# passed for any tests but failed on performance and random tests. And always result different for 1 (Expected: 405 But was: 404 for example). Whats wrong with this tests?
Approved
Hi,
Several things here...
First: Python translation (Might need a moderator for approval: the original author has not been connected this month. But maybe he will come back. Who knows... ;) )
Now, the issue part (coming from Java):
I strongly suggest to update the test cases in each languages so that they match the tests I implemented in the python translation.
Cheers,
B4B
Note: if the author doesn't show up and a moderator approve the python version, I'll update the Java version myself. But someone will have to do the JS and C# versions.
Hey, thanks for the python translation! Your suggestions sound good and hopefully I'll have time to implement them on the weekend, but feel free to update the test cases for Java if you feel like it :) That might actually be a big help since I'm not as familiar with Python, meaning the Java test cases may be a good reference for me when applying the necessary changes to C# and JS.. Cheers and happy coding!
Thx for the approval. :)
Java tests updated!
I did move your solution in the test case too: it's not a good idea to put the solution in the preloaded part, generally. (btw: your solution is really efficient! But mine is shorter and more general... ;p (The guy who searches for comfort where he can... ;o ))
I let the issue open, waiting on modifications of JS and C#.
Cheers,
B4B
Fixed JS version.
Fixed C# version.
Have it, But some suggestions about description to you.
In array, the goal line is the last row(r-1), but in the descripton, your example is put the line at top
Why not show it like this:
and most of these "picture" are confused, like this:
They are all mixed up together. May need to re-layout ;-)
done.
JS version, The arguments of this example testcase perhaps should be
inputGrid, 2, 1, 0, 0
Thanks, I'm aware of this issue. Unfortunately the codewars website seems to keep timing out at the moment so I'm unable to update the test cases. Shouldn't be long though..
:(
Same error in C#
This comment has been hidden.
Using of preview.codewars.com could help, if(!) the problems are because of timeouts!
It seems a server issue, jhoffner just reboot his server
resolved
This comment has been hidden.
Good idea using flood fill, but not quite efficient enough.
It works fine if you exclude the downwards direction. :]
This comment has been hidden.
Thanks I'll look into this
Yup, have been able to recreate this issue. Will update the solution as soon as the the codewars website stops timing out.. Have found the problem (used the wrong variable as an index somewhere) and fixed it, but am still unable to publish the changes. "The server timed out while trying to publish your changes."
Update: OK, so the C# and Javascript versions have been updated and should now work correctly. I've also lowered the maximum rows and columns to 2000 and 500 respectively. For some reason trying to publish changes to the Java version always results in a timeout, so it has not yet been updated. Edit: The Java solution should now also be working correctly.
Marked as resolved.
My algorithm works for small sizes, but fails on bigger ones. (Finds less paths than expected and is off by less then around 12.) Is there a way to inspect the larger grids to figure out what went wrong? I tried to solve this by walking every possible path, setting flags when a goal was found (to account for multiple paths leading to the same goal) and returning the sum of all flags.
Are you perhaps allowed to move down under certain conditions?
Also, I regularly get this error from "PerformanceTest" (but not always) and can't figure out why. If someone got any ideas that would be great.
Try submitting your code again, as the issue should now be fixed (if you are using C# or Javascript). There was a glitch in the matrix.. sorry
Yup, C# works now. Thanks, fun kata.
FYI the test case called
singlePath
has an input grid with different size to what the passed rows/columns parameters say.Good find, thanks!
I was wondering why bother passing
rows
andcolumns
at all?Solution can get just those numbers from the input grid dimensions.
True, you could check the length of the array at grid[0] to get the number of columns. However, the grid is a jagged array rather than a two dimensional one and could technically contain arrays with differing lengths, even though in this kata that won't be the case. I could update the C# (and Java?) versions to use a 2d array, but I believe Javascript doesn't support this and would still need to use the jagged version. Using rows and columns seems a bit more expressive than grid.Length and grid[0].Length, but does make the method signature bulkier.
If you get stuck and aren't sure how to approach this problem then you can read through the following discussion: http://answers.unity3d.com/questions/1229414/very-basic-pathfinding-for-infinite-runner.html#answer-1229436