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.
There are only 2 types of solution, which both presents in that kata. Input being numbers allow more specific operations, but this is a trick more than an actual difference.
This is not properly tested: the only relevant test is
contains(100, 0)
, which already contains0
.The solution from that kata passes this kata. But since this is with numbers only, other types of solutions also pass here. Tough one to call, but I would second that this is a duplicate.
This kata does not look different from https://www.codewars.com/kata/59daf400beec9780a9000045 besides the input being represented as numbers.
I am not sure:-) This example is explained in the description.
Wait, but aren't 101 and 107 primes in the range [100, 110] with a prime gap of 6? That should be correct, right? I looked through the directions and saw that [101, 107] doesn't violate the rules. (Never mind I read the description again)
In your code, before returning your array, print it to see what happens. Instead of returning "null" your code returns
[101, 107]
which is wrong (I tried your solution with a correct printing of the returned array); you should read carefully the complete description.It's not garbage; it's the way that Java prints array...
If you don't know how to print array as a string google "java print array". Good luck!
Yes this happens every time it checks for null, including the sample tests.
@realJarJarBinks
Does returning null for the (6,100,110) test case cause that problem for you as well?
I flagged your code as spoiler and indeed I was too quick to do this, but I did not do this because it was code. I was convinced that this kata is missing random tests in Java (I remembered this wrong), and I thought that your example simply solves the kata by counting the test cases. It's not the case here, so I un-flagged the comment.
However I think I am still missing something, because I do not see how this example helps and how it addresses OPs question. It passes sample tests, true. But what exactly does it prove about the full test suite?
Is it a problem with my computer? When I return null, it returns something like J@2eydhe74 or garbage like that and marks it as incorrect.
How is a hardcoded example of the tests behaving correctly a spoiler? I'm unsure why that was flagged, and I think it was a useful addition to a spoiler-free discussion. It seems like someone saw code and assumed it was a spoiler without even reading the code.
This comment is hidden because it contains spoiler information about the solution
I am using Java.
what language are you talking about?
Loading more items...