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.
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.
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).
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.
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.
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 tohasOwnProperty
ensures that the keys are in the immediate object; not any inherited prototype ones.Thank you for the kata :)
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.
Unnamed is right, the expected value for n∈[0,2] should be 0, since 0 is considered as an even number AFAIK.
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 (??).
Yeah, that's what the tests have now (for
n<16
). I don't know what the optimumn
is.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.
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).
Hi andrewMacmurray!
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.
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.
Thanks for your feedback - appreciated. I'm not quite sure what you mean - could you expand a little please
You're quite right, noted and updated. Thanks.
You must return a string not a number :)