4 kyu

Escape the Mines or die !

Description
Loading description...
Algorithms
Data Structures
Graph Theory
  • Please sign in or sign up to leave a comment.
  • JohanWiltink Avatar

    Haskell update

    does not add random tests and
    does not move Move to Preloaded, but

    copies, 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.

  • JohanWiltink Avatar

    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 in Preloaded, and though it will invalidate current solutions, that can still be done. )

  • JohanWiltink Avatar

    there will be only one correct path

    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.

  • Kacarott Avatar

    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.

  • stepa1000 Avatar

    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?

  • harmaa Avatar

    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

    • there is no such requirement in the description. The goal is to find a path in general.
    • it's said explicitly: "there will be only one correct path"

    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."

  • Voile Avatar

    Approved ;-)

    I'll add a JS translation soon(TM).

  • Voile Avatar

    Needs JS translation ;-)

  • markpearse Avatar

    Three problems in the test cases

    1. A 7x7 test cases is actually 7 x 6

    2. 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.

    3. 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

  • airt Avatar

    In the test case "Should work with complex path (7x7 map)", I got this failure:

    Should work with complex path (7x7 map)
     Should return the right moves
    expected: Just [D,D,R,R,R,R,R,D,D,L,D,L,U,L,L,D,L,D]
     but got: Just [D,D,R,R,R,R,R,D,D,L,L,L,L,D,L,D]
    

    D,L,U has been replaced with L. It seems to be the valid answer as well.

  • bartavelle Avatar

    I get the following failure with the full test cases:

    Should return an empty list, since we're already at the goal
    expected: Nothing
     but got: Just []
    

    Apparently my program returns an empty list, which seems to be the correct answer, but the test case expects Nothing.