Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • Profile-pic

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

  • Profile-pic

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

  • 16679193?v=4

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

  • 9571508?v=3

    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.

  • 7568004?v=4

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

    edit -- solve thanks you very much

  • 9571508?v=3

    The second one falls under this condition:

    For this kata, single digit numbers will NOT be considered numerical palindromes.

  • 7568004?v=4

    no i dont use it

  • 9571508?v=3

    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.

  • 7568004?v=4

    This comment is hidden because it contains spoiler information about the solution

  • 11790059?v=4

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

  • 14002692?v=3

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

  • Profile-pic

    read the description again.

  • Profile-pic

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

  • 5585183?v=3

    You have to be Infinite in your thinking

  • 21692852?v=3

    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?

  • Loading more items...