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.
Perfect solution!:)
I have added more.
Description and example updated.
Tests fixed.
Somehow I can't use
#context
inside describe block. Codewars doesn't have it?undefined method `context' for main:Object (NoMethodError)
By the way, how do you want to test it with random inputs? For instance, we will have random elements at array or random number - in which way you will know that answer will be correct, if you don't know the actual inputs? Looks like the only way is to establish formula inside test, but it's the same what method for correct answer do, so it doesn't seem like a truthful test.
That's the default test template for kata maker's reference. It's not an actual example test by any stretch. The fact that you see them in other katas means that they haven't done their jobs adding example tests either, and you should raise an issue on their katas too for that (unless example tests is not applicable for the kata).
Yes, random tests means tests with randomly generate inputs.
Do u mean cases when we have, for instance, 10 and 20 at array for number 15?
Which situations u want to cover as well?
I have added sample test as "#TODO:", since I found such approach at the most of other katas.
What do you mean under "random" tests? Tests with randomly generated numbers?
Needs example tests and random tests.
Also please don't use
Test.expect
, useTest.assert_equals
.It's not specified what should be returned when there're two different closest numbers.
Too few tests.
Yes, but I don't like expression with
else
insidecase
. It's not so much informative.Readable and efficient (only hit .size once):
Yes. You can compare them with '<' for example.
Loading more items...