Solution to problem024 by progressively generating each lexographical permutation