Ad
  • Custom User Avatar

    Nice feedback. I will consider adding additional tests. At this writing there are many translations of this kata. All are likely to have the same issue.
    The challenge is in coming up with good test cases and I've failed that if 1027 is the only number to require a -1 return for a 0 in the leading position (we should have a whole family of these.)
    I will look into adding this.

    Thanks

  • Default User Avatar

    I managed to get my first, incorrect solution through the tests. The issue that my solution was not initially dealing with was related with the 0 digit getting in the beggining of the number. This was caught by the test with the number 1027. In this case, the expected output is -1, since the digit 1 can only be replaced by 0. I think there should be a test with a number like 2013. I managed to satisfy the 1027 test by just returning -1 for a number that ended up with 0 in the first position, while my algorithm was still incorrect. It would also reject a number like 2013 returning -1 instead of producting 1320 which is the expected answer.

    This is my first comment, so excuse me if I don't know how to post formatted code demonstrating this issue.
    I think you can see my first accepted (incorrect) solution for this.