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.
not stack safe recursion...
The random tests are indeed random, but laughably weak because both
k
and the range ofA[i]
are too small compared tolen(A)
, so the maximum difference almost always saturates.https://www.codewars.com/kata/reviews/5ab7f3b4521cd1b3fd002d54/groups/6513dbca00b8830001ae92b9
This comment is hidden because it contains spoiler information about the solution
thanks for giving refer
scala.collection.immutable.StringOps
, conversions inscala.Predef
.Was not aware filter can be applied on String in Scala because getClass() only returns java.lang.String. There is filter() method in java.lang.String class. What is the class to look for the documentaion scala string (if there is something like that)?
val s = "hello"
println(s.getClass())
Not sure why you got down-votes for this. If I understand CodeWars Kyu system correctly, this is a much more trivial problem than the ranking suggests. You're just pointing that out.
This will fail if arr contains any NA or NaN elements.
This comment is hidden because it contains spoiler information about the solution
Yep, thanks. Also, please fix the function name in the sample tests, it's still camelCase.
@dolamroth you are right, I had a stupid mistake in my code where I was introducing rounding errors on the division by 2 for very large n. Sorry for that. Now it's fixed and your solution should pass. Can you try submitting it again?
@Voile thanks, it's corrected now.
I've copied my solution from the regular kata. It passes all the sample tests, but shows wrong results in the test section, which is kind of strange...
Python function name should be in snake_case, so
two_by_n
, nottwoByN
.I added a Python translation, let me know what you think!
Loading more items...