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.
This comment is hidden because it contains spoiler information about the solution
You can view my solution. I think my solutin may be one of the fastest anwsers, though the code is a little bit much.
As you've determined, the trouble with considering all permutations only to pick the next smaller one in the set is that there are so many permutations with most of the larger numbers -- not to mention the inefficiencies of going between integral and string values. If we had ten digits, the number of ways of permuting those ten digits is 10 factorial (10 * 9 * 8 * ... 1 = 3,628,800 permutations when you only care about one -- 10 digits for the first, 9 for the second, 8 for the third... etc.). You don't need to consider all 10 factorial permutations to find the next smaller - there's a simpler more efficient way of getting the answer.
So try these suggestions:
Once you get it, the algorithm isn't significantly more complicated than the one you already have, but it will perform much better. When you find the solution, celebrate -- but don't lament that it took you as long as it did.
I hope this is enough to get you unstuck and that you're not too frustrated to give it a go.
Cheers!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution