6.9.7 Checking for a permutation: is_permu
A permutation can be written as a list, but not every list corresponds
to a permutation. The is_permu is a boolean function which
checks to see if a given list is a permutation.
-
is_permu takes one argument:
L, a list.
- is_permu(L) returns 1 if L is a permutation and returns
0 if L is not a permutation.
Examples.
-
Input:
is_permu([2,1,3])
Output:
- Input:
is_permu([2,1,3,0])
Output: