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.
Sorry!
While your point is interesting, it goes without saying. Changes to the task are outside the task's scope.
This comment is hidden because it contains spoiler information about the solution
The fact that lightest's question is 3 years old and no-one has answered it may indicate that no-one here actually had such a thought process, i.e. the task was recognised as "known problem x, with known solution y" and the solution was just copied from somewhere, and all the explanations of it are canned (which is why none of them make sense from the perspective of someone who's only familiar with the task description). So, if you're like lightest (or me), don't be too disheartened if you couldn't come up with this solution from scratch from the task description. There may be only one person in the history of the world who's done that, and they may have even started from a clearer task description!
Yup you are right, tests in JS and a couple of other languages (not all) pass -1 in some fixed tests (but not in random tests), and handling of negative numbers is not mentioned anywhere.
I just found the "Show Kata Test Cases" section (on this Discourse tab), and it shows that the tests do pass a negative number in the JS version.
It depends on how kata is authored. It's up to the kata author what they put in assertion messages and logs, that's why you can see inputs in some tests, and not in others.
As much as I see, JS version does not pass negative numbers as input, and my solution does not handle negative inputs either. However, the input can be 0. Your solution could fail on 0, or had some other error.I am blind or something :|Isn't logging the inputs outside the scope of the challenge? CodeWars showed me the inputs for the other tests.
This was in JS. Actually, I don't know that the tests were passing a negative number, only that handling them in my code solved the problem.
You could: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#how-can-i-see-which-input-causes-my-solution-to-fail
In what language?
My solution wasn't passing the "smallest cases" tests, but I couldn't see the actual value(s) the tests were passing to my function. This is artificially unfair. Perhaps this is a problem with CodeWars rather than this kata?
Turns out the "smallest cases" tests were passing a negative number! This isn't hinted at in the instructions.
This could start on 3 and doesn't have to check every number, e.g. 4.
Sorting all the numbers just to get the smallest...
This comment is hidden because it contains spoiler information about the solution