Cool permutations

In this problem, we will say that a permutation is cool is it does not
have two adjacent consecutive numbers. Given n, print all the cool
permutations of {0, …, n − 1}.

Input

input consists of several cases, each with an n between 1 and 9.

Output

For every case, print in lexicographical order all the cool permutations
of {0, …, n − 1}. Print a line with 20 asterisks at the end of every
case.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:06:42.554Z

© Jutge.org, 2006–2026.
https://jutge.org
