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.
got it, thank you!
This comment is hidden because it contains spoiler information about the solution
is there any reason to use
nth / 10 | 0
instead of
Math.floor(nth / 10)
?
Me too, I don't get it either :(
It's a comment, like a signature, but most of the people that submitted it just copied it with signature and all to show of the work of someone else.
And they didn't even bother to fork it, just litteral copy paste.
This comment is hidden because it contains spoiler information about the solution
Thank you for nice explanation! However on 5th line, I think after second = there shouldn't be P(n-1), but only P(n-2)
IMO the descriptions are okay. Closing.
iheshi, because 105881 doesn't have 2 '5's and '0's in it to make the number 105501. The largest palindrome possible is when you arrange it as 081518, then drop the leading 0.
Still can't understand.
As 937 * 113 = 105881 and the largest palindromic number that can be arranged from this result is: 81518.
Why it's not 105501? Why it's 81518?
Go take a look at:
https://en.wikipedia.org/wiki/Combination
I consider this kata as a variation of the
project-euler-113
.IMHO, for this solution, it's not a best practice to do division k times in order to calculate the number of k-combinations...
This comment is hidden because it contains spoiler information about the solution
slice() is used to get a clone of row, so that the following sort() would change the clone instead of row itself.
This comment is hidden because it contains spoiler information about the solution
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.Loading more items...