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.
Retired due to it being to close a duplicate to the RangeExtraction kata.
Thanks, added one more test as You suggest.
I suggest adding a list which starts with a number other than 1 to the tests. I spotted at least one solution that would be obsolete if this test were included.
I agree with you, but I think that my version has a right to exist
This is almost a complete duplicate of Range Extraction, except that provides an array of numbers, and expects a dash only when there is a contiguous range of 3 or more integers.
Thanks, added one more test, correct description
First:
Missing check for a single last number while saving:
Test.assertEquals(createRangesString('1,2,3,4,5,7,8,9,11'),'1-5, 7-9, 11' );
My first try failed with such string but it let me save even if the algorythm was failing with a single last number.
Second:
in the description you use function named minimiseString(str) but into code function's named createRangesString(str). Just a minor thing but this could be a bit confusing.
Thank you very much for your advice and for correcting my sloppy English)
I agree that it is wrong to allow non-numeric characters and removed it from the tests. I also changed the name of the function a bit, but still left the input and output parameters as strings. I think it will help improve the skills of working with strings.
There are a few minor issues from my perspective:
It's confusing why in the case when there are two numbers next to each other, 17 and 18, why they'd be outputted seperately instead of combined into one range 17-18.
The phrase "Numbers in a string in ascending order" in the description should be "The numbers in the string will always be in ascending order.".
It feels a bit arbitrary to me why you'd have the restriction that the numbers are in ascending order, but then also allow non-number input.
Those minor issues aside, just as a suggestion, this question would be more clear to me if instead of being minimiseString, it was createRanges, which would take an unordered array of numbers, e.g. [1, 3, 2, 5, 4, 9, 8, 7], and returns a sorted array of ranges, e.g. [[1, 5], [7, 9]].