Problem 3437 · Medium

Permutations III

Build permutations left to right, skipping any value whose parity matches its neighbour; trying values in order yields them sorted.

Open the interactive visualisation