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.

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. If n-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.

n.toString().split('').reverse().join() reverses the number as a string

1 * converts the string to a number without changing the value.

Second line:

n - r is truthy when the number is not a palindrome (e.g. 125 - 521 is not 0 so it's truthy)

If it IS a palindrome, then n-r will be 0 which is falsy so it short circuits to avoid another recursive call

The truthy return values just return the number on the right side of the &&, so if it took 3 iterations for example, then the "final" return value would end up being something like:

Random r = new Random();
means that you create an object of type Random, new Random() initializes it, later you can use later to generate random numbers by calling
r.Next(); which returns a non-negative random integer
Next(Int32); returns a non-negative random integer that is less than the specified maximum
Next(Int32, Int32); returns a random integer that is within a specified range

Note that it is somewhat similar to creating an array, list, or an object of the type of a class
int[] i = new int[5]; You create i of type int[] and initialize it specifying its size which is 5
List l = new List(); You create l of type list and initialize it

if we have a class named TheClass, we can use its methods and public variables by making an object of its type and initializing it
class TheClass
{
public int n = 0;
}

class CallerClass
{
TheClass obj = new TheClass();
int nFromTheClass = obj.n; // nFromTheClass will be 0
}

If you have any other questions, please do not hesitate to ask,
Thank you for the question

if you look at the characters of 1875, the biggest symmetrical number in it is simply 8 because every character is unique.
since 8 is the biggest character, it is also the biggest palindrome.

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?

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. If`n-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.First line:

`n.toString().split('').reverse().join()`

reverses the number as a string`1 *`

converts the string to a number without changing the value.Second line:

`n - r`

is truthy when the number is not a palindrome (e.g. 125 - 521 is not 0 so it's truthy)If it IS a palindrome, then n-r will be 0 which is falsy so it short circuits to avoid another recursive call

The truthy return values just return the number on the right side of the &&, so if it took 3 iterations for example, then the "final" return value would end up being something like:

`return true && 1 + (true && 1 + ( true && 1 + (0) ))`

With each set of parens evaluating to just the number each time the function returns... so the whole thing evaluates to 3

Random r = new Random();

means that you create an object of type Random, new Random() initializes it, later you can use later to generate random numbers by calling

r.Next(); which returns a non-negative random integer

Next(Int32); returns a non-negative random integer that is less than the specified maximum

Next(Int32, Int32); returns a random integer that is within a specified range

Note that it is somewhat similar to creating an array, list, or an object of the type of a class

int[] i = new int[5]; You create i of type int[] and initialize it specifying its size which is 5

List l = new List(); You create l of type list and initialize it

if we have a class named TheClass, we can use its methods and public variables by making an object of its type and initializing it

class TheClass

{

public int n = 0;

}

class CallerClass

{

TheClass obj = new TheClass();

int nFromTheClass = obj.n; // nFromTheClass will be 0

}

If you have any other questions, please do not hesitate to ask,

Thank you for the question

if you look at the characters of 1875, the biggest symmetrical number in it is simply 8 because every character is unique.

since 8 is the biggest character, it is also the biggest palindrome.

Can you break down the process of 'tokens = exp.exec(a)' and '!!tokens[i + 1]'?

Thanks!

'Random r = new Random();'

Can anyone explain how does this work?

Thanks!

Anyone can explain the formula?

Thank you

## Loading more items...