Numbers in a bag
Given a permutation, get next one
- From permutation vector
- take right-most number and put into bag
- if there is larger number in bag
- put it into vector at left-most empty position
- stop
- repeat while more numbers in vector (no greater permutation)
- Refill vector with numbers in bag
- find smallest number in bag
- place in left-most empty position
- repeat until vector full (no more numbers in bag)
Eventually get to 4,3,2,1,0