My friend @dastevens gave me the explanation. My solution works on the sample test and not the random test because I changed num without knowing it. Why ? In my solution, I wanted to work on a copy of num, so I wrote :

var numInc = num

But in Javascript, var numInc = num does not create a real copy : it just copies the reference (address) of num in memory. As a result, any operation on numInc will also modify num itself.

(This would not be the case if we worked on strings, since strings can never be modified).

And this is why, we think, the sample tests are passed but not the random ones. Let's say that the author wrote a function, the solution of the kata, named "kataSolution()" ;

the sample tests do not run kataSolution(). The expected result is already provided. The tests only compare this expected result with that of incrementer(). In that case everything's OK.

but in the random tests, kataSolution() has to be run, to calculate the solution. And it seems that it is run AFTER incremeter(), which modified num. So kataSolution is run on a modified num. Example :

num = [1, 2, 3]

myIncrementer(num) = [2, 4, 6] , but it also transforms num in [2, 4, 6].

so kataSolution(num) is in fact kataSolution(myIncrementer(num)) ! That's to say [3, 6, 9] instead of expected [2, 4, 6].

We suggest changing the description to say do not change the input array, and add a test that fails if the input array is modified.

Thanks to the author and to dastevens to make me realize this noticeable feature...

No problem, for others reference, you can only rearrange 1212 to the palindromes 1221 or 2112. Other katas of this series test for palindromes included in the number, not this one.

I really don't understand this. I can pass 4/5 tests, and about 25ish of the extended tests if I do a little creative programming, but I can't figure out how you want this rounded. It seems inconsistent, and doesn't seem to follow the mathematical model you describe. Same issue both in Ruby and JS. Any hints?

My friend @dastevens gave me the explanation. My solution works on the sample test and not the random test because I changed num without knowing it. Why ? In my solution, I wanted to work on a copy of num, so I wrote :

var numInc = num

But in Javascript, var numInc = num does not create a real copy : it just copies the reference (address) of num in memory. As a result, any operation on numInc will also modify num itself.

(This would not be the case if we worked on strings, since strings can never be modified).

And this is why, we think, the sample tests are passed but not the random ones. Let's say that the author wrote a function, the solution of the kata, named "kataSolution()" ;

the sample tests do not run kataSolution(). The expected result is already provided. The tests only compare this expected result with that of incrementer(). In that case everything's OK.

but in the random tests, kataSolution() has to be run, to calculate the solution. And it seems that it is run AFTER incremeter(), which modified num. So kataSolution is run on a modified num. Example :

num = [1, 2, 3]

myIncrementer(num) = [2, 4, 6] , but it also transforms num in [2, 4, 6].

so kataSolution(num) is in fact kataSolution(myIncrementer(num)) ! That's to say [3, 6, 9] instead of expected [2, 4, 6].

We suggest changing the description to say do not change the input array, and add a test that fails if the input array is modified.

Thanks to the author and to dastevens to make me realize this noticeable feature...

Exactly the same problem for me : sample tests all OK, random tests leave the array unchanged. Thanks for your help !

I cant understand why the number '115555' has 7 palindromes. 11,55, 555, 5555 anything else?

No problem, for others reference, you can only rearrange 1212 to the palindromes 1221 or 2112. Other katas of this series test for palindromes included in the number, not this one.

i failed at test 1212, it can be arrange into 1221 / 121 / 212

edit -- solve thanks you very much

The second one falls under this condition:

no i dont use it

Did you try using

`console.log(num)`

? 55 warriors have solved the kata in js so I don't think it's a kata issue.This comment is hidden because it contains spoiler information about the solution

If you are only testing for abc such that c > a and c > b, then you should consider indicating that in your details/instructions

@kkavita92, thanks for this nice kata! Cheers;)

read the description again.

how come (1212) is true ; it is not palindrome

You have to be

`Infinite`

in your thinkingI really don't understand this. I can pass 4/5 tests, and about 25ish of the extended tests if I do a little creative programming, but I can't figure out how you want this rounded. It seems inconsistent, and doesn't seem to follow the mathematical model you describe. Same issue both in Ruby and JS. Any hints?

## Loading more items...