4 kyu
Escape the Mines or die !
128ice1000
Loading description...
Algorithms
Data Structures
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.
Haskell update
does not add random tests and
does not move
Move
toPreloaded
, butcopies, adjust and extends the description from the previous kata, specifies coordinates and directions in the description, and fixes two test grids that had loops in them.
Since all examples in the description have same value for x and y, it's impossible to know which coord stands for which dimension, from the description.
I can read that sentence over and over and still get mind-f*cked
When using (x,y) coordinates in a language that uses (y,x) coordinates, directions lose their meaning in relation to the grid as presented by the examples and example tests. They should be specified explicitly. Down becomes right, right becomes down, left up, and up left, relative to the language indexing of the map.
(
Move
also should have been inPreloaded
, and though it will invalidate current solutions, that can still be done. )This is incorrect. Currently, solving the kata depends on reverse engineering the descent order the reference solution uses.
ETA: having cycles ( the 2x2 open space in the 12x12 test ) also means the whole past path has to be remembered, instead of just the last step. so it really affects the specs and the possible implementations. alternatively, ask for the shortest path - but that also completely fscks over the specs and the implementations. better fix that grid.
Shortest path is the way to go here, it's a blue kata afterall. If only 1 path should be possible, authoring the kata would become purple and solving it yellow. It currently is a mess (no random tests, messed up coord system)
The kata which is linked in the description has since been retired. This kata should remove the link, and fill in the description with the rules (copy paste from the other one?) so that it is self sufficient.
Using (x,y) coordinates instead of (y,x) coordinates should not be hidden behind a link, in examples, and in initial code.
It's too late to fix the encoding I guess, and I agree it's arbitrary ( though obviously at odds with language convention ), but it should be clearly, explicitly specified ( preferably in bold blinking all-caps. or hot pink, at least ).
It seems to me, or simple tests are contradictory.
Passing a 2 by 2 test is possible with an index (0,0) for the lower right corner and with an index (1,1) for the upper left corner.
Passing a 3 by 3 test is possible with an index (0,0) for the lower left corner and with an index (0,2) for the upper left corner.
Passing a 5 by 5 test is possible with an index (4,4) for the lower right corner and with an index (0,0) for the upper left corner.
Am i wrong somewhere?
Are you by any chance using (y,x) coordinates relative to up, down, left, right ( and then possibly inverted in one or both directions ) ? The kata is using (x,y) ( like mathematical ) coordinates, with an inverted y-axis and the origin in the upper left.
Unfortunately, my code fails at the final test:
Should work with complex path (12x12 map) Should work Test Failed expected: Just [D,D,R,R,U,U,R,R,D,D,R,R,U,U,R,R,D,D,R,R,R,D,D,L,D,L,L,L,U,L,L,D,L,L,U,L,L,D,L,D,D,R,D,D,L,D,D,R,R,R,U,U,U,U,R,R,D,D,R,R,D,R,R,R,R,D] but got: Just [D,D,R,R,U,U,R,R,D,D,R,R,U,U,R,R,D,D,R,R,R,D,D,L,D,L,L,L,U,L,L,D,L,L,U,L,L,D,L,D,D,R,D,D,L,D,D,R,R,R,U,U,U,U,R,R,D,D,R,R,D,R,R,R,U,R,D,D]
My code does not try to find the best path, but
A past version of my code just hung at the final test. It turned out to have been due to a loop in the map. Note that a square 2x2 of empty cells in the map makes up a loop too. But, again, it contradicts to the parent kata description (https://www.codewars.com/kata/escape-the-mines): "The map will never contain any loop, so there will always be only one possible path."
I got the same result, and cheated to pass the test by changing the traversal order. :)
Approved ;-)
I'll add a JS translation soon(TM).
I love you
Words are worthless, show your love by completing SKI and Sloth ;-)
maybe a python or java version too? ;o
Any news of this JS translation ? Too bad I know nothing about Haskell. After some consolidation in Rust, Haskell might the next language I'd like to learn
Needs JS translation ;-)
Three problems in the test cases
A 7x7 test cases is actually 7 x 6
One case has expected solution: [D,D,R,R,R,R,R,D,D,L,D,L,U,L,L,D,L,D], but there is actually a shorter path: [D,D,R,R,R,R,R,D,D,L, L, L,L,D,L,D] which avoids a detour round a small cul-de-sac.
The configuration for the last two test cases (12x12) has two equally good paths, since there is an open square at 2,10 3,10 2,11 3,11; so paths: ...D,R,R, R,U, U,U..., ...D,R,R, U,R, U,U... both work.
I have editted the test cases to fix the size and remove the ambiguities. I hope the changes seem OK to you,
Mark
I'll modify the map, wait
All what you said make sense. The first two are fixed now.
Last one fixed. I've done the following modify:
The
@
is the added one. Thank you for your feedback.This comment has been hidden.
In the test case "Should work with complex path (7x7 map)", I got this failure:
D,L,U
has been replaced withL
. It seems to be the valid answer as well.The map was
I've changed it into
And your answer is correct.
I get the following failure with the full test cases:
Apparently my program returns an empty list, which seems to be the correct answer, but the test case expects
Nothing
.wait
Actually the test case is something like
So
Nothing
is expected. I didn't mention this in the description, I'll add it now. Thx for feedbackDone.