Function pc_next_permutation

Lexicographic permutation function.

This is a special type of permutation which involves the order of the set. The next
lexicographic permutation of '32541' is '34125'. Numerically, it is simply the smallest
set larger than the current one.

The benefit of this over a recursive solution is that the whole list does NOT need
to be held in memory. So it's actually possible to run 30! permutations without
causing a memory overflow.