And finally, the function to calculate the next largest number itself, relying on the idea that if we sort in numerical ascending order and filter out all the items less than the requested number, then the first one remaining must be our next largest number.
Here's mine.
First, a function for permuting the digits (using recursion):
Next, a sorting function:
And finally, the function to calculate the next largest number itself, relying on the idea that if we sort in numerical ascending order and filter out all the items less than the requested number, then the first one remaining must be our next largest number.
Full code and tests in gist: gist.github.com/kerrishotts/a0a96d...