Ad
  • Default User Avatar

    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.

  • Custom User Avatar

    Cool, nice one :-)

  • Custom User Avatar

    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.

    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]]
    
    Test.it("Test Cases") do
      Test.assert_equals(maze_runner(maze,["N","N","N","W","W","W","N","N","W","W","S","S","S","S","W","W","N","N","N","N","N","N","N"]), "Finish", "Should return Finish")
      Test.assert_equals(maze_runner(maze,["N","N","N","N","N","N","N","N","W","W","W","S","W","W","N"]), "Lost", "Should return Lost")
      Test.assert_equals(maze_runner(maze,["N","N","N","N","N","E","E","S","S","S","S","S","S"]), "Dead", "Should return Dead")
      Test.assert_equals(maze_runner(maze,["N","W","W","W","W"]), "Dead", "Should return Dead")
      Test.assert_equals(maze_runner(maze,["N","N","N","N","N","N","N","N","N","S","S","S","S","S","S","S","S","S"]), "Lost", "Should return Lost")
      Test.assert_equals(maze_runner(maze,["N","E","E"]), "Dead", "Should return Dead")
      Test.assert_equals(maze_runner(maze,["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"]), "Finish", "Should return Finish")
      Test.assert_equals(maze_runner(maze,["N","W","W","W","N","N"]), "Lost", "Should return Lost")
      Test.assert_equals(maze_runner(maze,["N","N","N","E"]), "Lost", "Should return Lost")
      Test.assert_equals(maze_runner(maze,["N","N","N","W","W","W","N","N","W","W","S","S","S","S","S","S"]), "Dead", "Should return Dead")
      Test.assert_equals(maze_runner(maze,["N","W","W","W","N","N","N","N","W","W","S","S","S","S","W","W","N","N","N","N","N","N","N"]), "Finish", "Should return Finish")
    end
    
  • Custom User Avatar

    Hi Animoni. Which language? please provide more info on the test case. :-)

  • Custom User Avatar

    Same here:( That is the only fail I have :(

  • Custom User Avatar

    Fair comment.

  • Default User Avatar

    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.

  • Custom User Avatar

    Ah, thanks!

  • Custom User Avatar

    Once you've solved a kata you can click on the language drop down menu from the Details 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 :-)

  • Custom User Avatar

    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?

  • Custom User Avatar

    Cool, nice one :-), thanks for solving.

  • Custom User Avatar

    Thanks for this reply @zebulan, hope it helps @Edwuards1327

  • Custom User Avatar

    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. :-)

  • Custom User Avatar

    @Edwuards1327,

    You need brackets after if(el.indexOf(2) != -1) because it's more than one line.

    if(el.indexOf(2) != -1) {
      vertical = i;
      horizontal = el.indexOf(2);
    }
    
    

    This line causes your other error: var current = maze[vertical][horizontal];

    > a = undefined
    undefined
    > a[3]
    VM221:1 Uncaught TypeError: Cannot read property '3' of undefined
        at <anonymous>:1:2
    
    

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

    try {
      var current = maze[vertical][horizontal];
    } catch(err) {
      return 'Dead';
    }
    

    With those two minor changes, your solution passes.

    Hopefully that helps!

  • Custom User Avatar

    @adrian.eyre,

    Python 2 isn't available.

  • Loading more items...