C++ algorithm for N! orderings

c++, factorial, permutation

Solution

See std::next_permutation

Problem

I have a list of N items and I am wondering how I can loop through the list to get every combination. There are no doubles, so I need to get all N! orderings. Extra memory is no problem, I'm trying to think of the simplest algorithm but I'm having trouble.

Original source

Related problems