Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
Rock, Paper, Scissors without conditional logic.
And remember, 5am coding leads to erroneously calling a variable the "mean" when it clearly isn't divided by the number of values.
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.
@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.)
That's a problem with your code, not a kata issue:
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.
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].