in reply to Re^3: Next permutation
in thread Next permutation

If you hit the highest digit as the first digit, then:
1. Sorting of remaining digits.
2. if you cannot sort any further, (ie.. it is already in reverse order) than sort from the beginning position. ( to return to the original number. 321 -> 123)

Replies are listed 'Best First'.
Re^5: Next permutation
by Marshall (Canon) on Feb 25, 2019 at 21:36 UTC
    If you want to learn Perl, I would like to see your attempt at this extra behaviour. Then I and the group can help you with that. The general approach here is "post a question", "get some info", "learn and experiment", "post another question based upon what you've learned and your experimentation".

    I've given you a start although I probably should have named rot_max_left() as shift_max_left(). I encourage you to give this a go yourself and post your code.