Ad
  • Custom User Avatar

    In javascript, the var in obj pattern will go through all of an Object's properties (keys) including all the keys in it's prototype chain. The call to hasOwnProperty ensures that the keys are in the immediate object; not any inherited prototype ones.

  • Custom User Avatar

    Thank you for the kata :)

  • Custom User Avatar

    I agree with Unnamed, I'll update the Kata now. That totally makes sense because there would be a number there. It just wouldn't be > 1.

  • Custom User Avatar

    Unnamed is right, the expected value for n∈[0,2] should be 0, since 0 is considered as an even number AFAIK.

  • Custom User Avatar

    For the moment I can increment n to 40. Worst case you can copy-paste the maze in a text editor on a large-enough screen (??).

  • Custom User Avatar

    Yeah, that's what the tests have now (for n<16). I don't know what the optimum n is.

  • Custom User Avatar

    That's a great idea! I just remembered that CodeWars JS runs on Node, so I can just console.log the maze on Codewars! The only issue is that some of the 12 random mazes will be too big and cumbersome to be visualized properly in the console (up to 100x100 arrays!). I updated the cases so that the first two mazes (of fixed content and sizes) plus the random ones which will are smaller than 15x15 will be logged. Let me know if you find this reasonable.

  • Custom User Avatar

    Since the upper bound is inclusive, there can't be no even number (in the proper logical sense of double negative). So I think it should expect 0 for 0 (and for 1 and 2).

  • Custom User Avatar

    Hi andrewMacmurray!

    • the test cases first verify your solution for the first maze (1st group of tests), and then repeats the same group of tests for different mazes (including some randomly generated ones). The description of the group of tests says "testing for 'n'th maze".
    • The group of tests first verifies the format of your solution (independent from the maze), and then checks the content of your solution (dependent on the maze).
    • Anyway, I tried just now submitting a solution as follows, matching the result in your comment.
    function getToX(maze){
      var path, values;
      return {path:[[0,0],[0,1],[0,2],[1,2],[2,2],[3,2],[4,2],[4,3],[4,4],[4,5]], values:["_","_","_","_","_","_","_","_","_","x"]};
    }
    

    You're right, it is a perfectly fitting solution for the maze in the 1st group of tests (same as in description) and, therefore, has passed all tests for that maze (1st test group). However, the same solution is not correct for all possible mazes of course, and will not pass for the second group of tests.

  • Custom User Avatar

    Thank you so much for taking the time to not just complete the kata but to test my testing.

    I would not have thought of circumventing it in that way - I will now.

    I have incorporated your random test which is similar, but far superior to mine, and re-published.

  • Custom User Avatar

    Thanks for your feedback - appreciated. I'm not quite sure what you mean - could you expand a little please

  • Custom User Avatar

    You're quite right, noted and updated. Thanks.

  • Custom User Avatar

    You must return a string not a number :)