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