I noticed that in Python too, some test inputs are not sorted. This contradicts the problem statement but it is possible to adjust solutions to cope with unsorted input easily enough.
Perhaps the problem statement should be amended to indicated that the overall array is not necessarily sorted, but some ranges within the array are.
I think something may be wrong with the test cases. Using Ruby btw, the last two are very strange.
Test Passed: Value == []
Test Passed: Value == ["1"]
Test Passed: Value == ["1->4"]
Test Passed: Value == ["0->2", "5->6", "9"]
Test Passed: Value == ["0->7"]
Test Passed: Value == ["0->7"]
Test Passed: Value == ["0->7", "9->10"]
Test Passed: Value == ["-2", "0->7", "9->10", "12"]
Expected: ["-2", "0", "-1", "-3->-2"], instead got: ["-2", "0"]
Expected: ["-2", "0", "-1->0", "-1->0", "-1"], instead got: ["-2", "0"]
it works, finally! :)
ty Giacomo it worked!
The random test cases were fixed, I forgot to check the basics: now is done!
['-3->0'] should equal ['-2', '0', '-1', '-3->-2']. Please fix.
This problem still exists in the Ruby tests.
Fixed (or so I hope), sorry for the inconvenience!
same problem using Python
['-3->0'] should equal ['-2', '0', '-1', '-3->-2']
Arrays should be sorted. It is an oversight from the Python and Ruby translator. I will ask him to fix up the test cases. Thanks for reporting this.
I noticed that in Python too, some test inputs are not sorted. This contradicts the problem statement but it is possible to adjust solutions to cope with unsorted input easily enough.
Perhaps the problem statement should be amended to indicated that the overall array is not necessarily sorted, but some ranges within the array are.
I think something may be wrong with the test cases. Using Ruby btw, the last two are very strange.
Test Passed: Value == []
Test Passed: Value == ["1"]
Test Passed: Value == ["1->4"]
Test Passed: Value == ["0->2", "5->6", "9"]
Test Passed: Value == ["0->7"]
Test Passed: Value == ["0->7"]
Test Passed: Value == ["0->7", "9->10"]
Test Passed: Value == ["-2", "0->7", "9->10", "12"]
Expected: ["-2", "0", "-1", "-3->-2"], instead got: ["-2", "0"]
Expected: ["-2", "0", "-1->0", "-1->0", "-1"], instead got: ["-2", "0"]
Such a nice and elegent solution. I always have this inkling that my code can be much cleaner. Well done.
That's sexy.