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.
Try making a test function that is very small and easy to follow. There are a few suggestions above.
Also, you may want to include a few lines that check how much time has elapsed and to exit everything when time is close to 3 seconds. In this case you will at least receive the test results to that point instead of losing everything due to time out.
You can call slice on them too! I personally find it more convenient to split a string up into an array, though (
str.split('')
), because iteration can be less of a hassle in some cases.the fitness function takes the chromosome in as a string parameter not an array. if you have an array of 50 strings and you wanted to find the fitness of one, you'd do the following. fitness( chromosomes[index]).
While I agree with the general sentiment, to be fair, it never asked for a sorted array.
[...] their ascending relative order.
plus the prominent examples made it pretty clear (to me) what was expected.Yeah, that's not what the description is asking for at all. Either the description needs to be changed (not recommended, since as JulianNicholls points out, it'd be doing only part of what a mergesort does, since it's not starting with sorted arrays), or the test fixture needs to be changed.
It makes sense, however in a mergesort merge operation, you will always be presented with two sorted arrays.
Incidentally, this Kata is a bit of a duplicate: http://www.codewars.com/dojo/katas/52336a4436e0b095d8000093