(pi)
return (n - c) % 2
Computes the parity of a permutation in array form.

    The parity of a permutation reflects the parity of the
    number of inversions in the permutation, i.e., the
    number of pairs of x and y such that x > y but p[x] < p[y].

    Examples
    ========

    >>> from sympy.combinatorics.permutations import _af_parity
    >>> _af_parity([0,1,2,3])
    0
    >>> _af_parity([3,2,0,1])
    1

    See Also
    ========

    Permutation
Computes the parity of a permutation in array form.
Computes the parity of a permutation in array form .
def _af_parity(pi):
    """
    Computes the parity of a permutation in array form.

    The parity of a permutation reflects the parity of the
    number of inversions in the permutation, i.e., the
    number of pairs of x and y such that x > y but p[x] < p[y].

    Examples
    ========

    >>> from sympy.combinatorics.permutations import _af_parity
    >>> _af_parity([0,1,2,3])
    0
    >>> _af_parity([3,2,0,1])
    1

    See Also
    ========

    Permutation
    """
    n = len(pi)
    a = [0] * n
    c = 0
    for j in range(n):
        if a[j] == 0:
            c += 1
            a[j] = 1
            i = j
            while pi[i] != j:
                i = pi[i]
                a[i] = 1
    return (n - c) % 2
def _af_parity ( pi ) : n = len ( pi ) a = [ 0 ] * n c = 0 for j in range ( n ) : if a [ j ] == 0 : c += 1 a [ j ] = 1 i = j while pi [ i ] != j : i = pi [ i ] a [ i ] = 1 return ( n - c ) % 2