Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Rock, Paper, Scissors without conditional logic.

  • Custom User Avatar

    And remember, 5am coding leads to erroneously calling a variable the "mean" when it clearly isn't divided by the number of values.

  • Custom User Avatar

    Oh man, looks like I skim-read the instructions and ended up bringing the pepper shaker instead of the salt. I should have paid more attention to that second drawn matrix, rather than looking at the first three elements and thinking "yeah I get it". I've finished the code for real now, and it's now a lot cleaner. Great kata and thank you both for the information.

  • Default User Avatar

    @JPR95 - by the way, since you are new to Codewars, a useful tip for debugging is to print your inputs to console so you can see better what is causing you to fail:

    how to print inputs Troubleshooting guide

    As @Chrono79 said, you will find that some tests are passing you an input that is indeed "unordered", but you still should be able to create the required "snail" pattern from them (because the "labels" of the elements isn't relevant, only their location in the input array - you could use letters instead of numbers and the kata still makes sense.)

  • Custom User Avatar

    That's a problem with your code, not a kata issue:

    JavaScript Completions 17985

    There are two fixed tests in javascript, one where the numbers are ordered in the array, similar to the first example, and another similar to the second example. Random tests contain random numbers. You must follow the snail pattern with them too.

  • Custom User Avatar

    I've written a function which I am almost certain should solve this kata, but I am having a couple of issues.

    If I click "Test", I get a failure message as the sample test which includes a 36-element array seems to want the numbers in ascending numerical order [1, 2, 3, 4, 5, 6, 7, 8, ..., 36] rather than the actual spiral pattern of [1, 2, 3, 4, 5, 6, 12, 18, 24, 30, 36, 35, 34, ..., 21].

    However, even if I hard code in an ascending numerical order for 36 elements, I am having an issue when I click "Attempt", where the numbers in the given array are not 1 to n, but instead seemingly random unordered numbers, such as [793, 58, 556, 635, 246, ..., 385].