On a gauntlet thrown by David Gries

SummaryIt is requested to design a program that will generate the N! permutations of the values from 0 through N — 1 in such an order that the transition from one permutation to the next is always performed by exactly one swap of two neighbours.