# Foreword – Permutation of the list.

The acceptable_permutation predicate (L, R) should succeed only if R represents an acceptable permutation of the L list.
Innuendo: [2,1,3] It is not an acceptable permutation of the list. [1,2,3] Because 3 did not change his position.
The outputs are supposed to be like this:

``````? - acceptable_permutation ([1,2,3], R).
R = [2,3,1] ;
R = [3,1,2] ;
false

? - acceptable_permutation ([1,2,3,4], R).
R = [2,1,4,3] ;
R = [2,3,4,1] ;
R = [2,4,1,3] ;
R = [3,1,4,2] ;
R = [3,4,1,2] ;
R = [3,4,2,1] ;
R = [4,1,2,3] ;
R = [4,3,1,2] ;
R = [4,3,2,1] ;
false.
``````

My outputs of my code however give:

``````? - acceptable_permutation ([1,2,3], R).
R = [1,2,3] ;
R = [1,3,2] ;
R = [2,1,3] ;
R = [2,3,1] ;
R = [3,1,2] ;
R = [3,2,1] ;

? - acceptable_permutation ([1,2,3,4], R).
R = [1,2,3,4] ;
R = [1,2,4,3] ;
R = [1,3,2,4] ;
R = [1,3,4,2] ;
R = [1,4,2,3] ;
R = [1,4,3,2] ;
R = [2,1,3,4] ;
R = [2,1,4,3] ;
R = [2,3,1,4] ;
R = [2,3,4,1] ;
R = [2,4,1,3] ;
R = [2,4,3,1] ;
R = [3,1,2,4] ;
R = [3,1,4,2] ;
R = [3,2,1,4] ;
R = [3,2,4,1] ;
R = [3,4,1,2] ;
R = [3,4,2,1] ;
R = [4,1,2,3] ;
R = [4,1,3,2] ;
R = [4,2,1,3] ;
R = [4,2,3,1] ;
R = [4,3,1,2] ;
R = [4,3,2,1] ;
false.
``````

My code is the following:

``````acceptable_permutation (list, list).

of (symbol, list, list).

of (x,[X|L1], L1).

of (x,[Y|L1], [Y|L2]): -
of (X, L1, L2).
acceptable_permutation ([] , []).

acceptable_permutation (L, [X|P]): -
from (X, L, L1),
acceptable_permutation (L1, P).
``````

Tell me where exactly the problem is, so that my outputs coincide with the correct outputs. I would appreciate very much if you show me exactly how it is done.