Computes the parity (even/odd sign) of a permutation