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.
Am I mistaken, or does this test case result:
✘ Expected: [118795765932835,0,1], instead got: [118795765932835,0,0]
contradict this:
(for Javascript)
This one ought to be the highest voted solution--both in terms of cleverness and best practices.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Is the translator also responsible for designing the test cases in the new language as well? Because my solution works when I run the random test cases myself but throws this error when I try to submit it on Codewars:
n.toString().split("").reverse().join()
reverses the number input but now it is in string format. Multiplying by 1 then coerces the string back into an integer.return n - r && 1 + palindromeChainLength(r + n);
It is important to note that
0 && (any possible value)
will return the 0 before even evaluating the second expression, since 0 is falsey. Ifn-r===0
, that means the number is a palindrome since only a palindrome subtracted by the result of its reverse number is ever equal to zero. Thus, the function will return 0. If it is not a palindrome, then it will return 1 + the function called recursively, until a recursion finally returns 0. So it would go 1+1+1+1+1.....+0 when a palindrome is finally formed by the addtion of the original number plus its reverse.why declare index outside the function's scope?
we get it, you vape
i lol'd
Clever, but this returns an empty array if all of the array's members' counts exceed the max.
Examples:
[3,4,5,3,4,5,3,4,5],2
[6,7,6,7,7],1
Very clean, well-designed solution. I learned a lot from it. Great work.
This comment is hidden because it contains spoiler information about the solution
a
In fact, you don't even need it for this particular method. #select will work directly on the Range object.