GoalQueneau Numbers were discovered by the French writer and mathematician Raymond Queneau, while member of the OULIPO.
A Queneau Number is a number N such that the sequence [1..N] can go through a series of spiral permutations (or "snail" permutations) and come back to [1..N] in exactly N iterations. The permutation consists in tracing a spiral from the last number of the sequence, spiraling towards the center. For instance, 5 being a Queneau Number, the permutations will start from the sequence
And go as follows:
The Nth line is always the same as the initial sequence, or else the number is not a Queneau Number.
One number N
N lines: the different steps of permutations, as a comma-separated sequence
IMPOSSIBLE if the number is not a Queneau number.
2 ≤ N ≤ 30
3,1,2 2,3,1 1,2,3
A higher resolution is required to access the IDE