Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.