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.
And is correct that way because inputs "... are always lowercase strings, and that each has at least two letters.". If that was not the case and arbitrary inputs would be allowed we'd also need checks for
null
and lengths in order to avoidNullPointerException
andIndexOutOfBoundsException
or alike.it work only if cases are equal
I would rather have more spaces to increase the readability of the code, but it's okay
Very efficient
Such an answer should not pass:
https://www.codewars.com/kata/reviews/5ba2f4cb19d12a69d50002af/groups/5ca95aec613d5d0001175036
Generate an array of random length with random
int
s, while ensuring that it contains exactly one(2,n,4)
tuple at a randomized location. Use your "model" solution to generate the correct answer, and then do anassertEquals
to compare yours with the user's answer. Throw this in a loop for a few dozen iterations.The point of randomized testing is to prevent hardcoded answers, so that the user has to actually solve the problem. Your kata should have one or more fixed tests methods, generally pulled from the sample tests, and any edge cases. Then at least one random tests method to block cheating.
How do I set up random tests?
This comment is hidden because it contains spoiler information about the solution
Thank you telling me. I wouldn't hava noticed
Typo in initial method name
Kata
should bekata
When I said "read the
Tutorial: creating your first kata
article", I actually meant it. Creating trash katas (and what's worse - spamming them) is highly dicouraged, so please don't.No, you should return.
It doesn't matter whether
a
is positive or negative. And ifb
was negative, the result would simply be truncated to0
.Then take a look at this article. And don't make any more bad katas.