Solution (source code)

= Solution

For $\sigma\in S_n$, let $P_\sigma$ be its <permutation matrix> and define
$$
\operatorname{sgn}(\sigma)=\det P_\sigma\in\{\pm1\}.
$$
Since a transposition exchanges two columns, it has determinant $-1$. Thus any expression of $\sigma$ as $r$ transpositions has sign $(-1)^r$, proving that the parity is independent of the expression. Moreover, $P_{\sigma\tau}=P_\sigma P_\tau$, so the <determinant> proves
$$
\operatorname{sgn}(\sigma\tau)=\operatorname{sgn}(\sigma)\operatorname{sgn}(\tau).
$$
Hence the <sign homomorphism> is a surjective homomorphism for $n\geq2$.

For any homomorphism $\varphi:S_n\to\{\pm1\}$, all transpositions have the same image because they are conjugate. Since transpositions generate $S_n$, image $+1$ would make $\varphi$ trivial. Surjectivity therefore forces every transposition to map to $-1$, and hence \b[$\varphi=\operatorname{sgn}$].