Solution (source code)

= Solution

For $n\geq1$, the integral <singular homology> of the <sphere> is $H_0(S^n)=\mathbb Z$, $H_n(S^n)=\mathbb Z$, and zero in other degrees. For $S^0$ there are two components, so $H_0(S^0)=\mathbb Z^2$. Choose an <orientation> generator $[S^n]$ for positive dimension. The <degree of a continuous mapping>[degree of a map] is the integer satisfying
$$
\boxed{f_*[S^n]=\deg(f)[S^n]}.
$$
To define a <local degree of a continuous map> at $x$ over $y=f(x)$, require $x$ to be isolated in that fibre. A small neighbourhood $U$ contains no other preimage of $y$, so $f$ maps $(U,U\setminus\{x\})$ to $(S^n,S^n\setminus\{y\})$. By <excision> their local top homology groups are both $\mathbb Z$, with generators fixed by the orientations. Multiplication by an integer in this induced map defines $\deg_xf$. Without fibre isolation, this particular local-degree definition is not in general available.

If $f^{-1}(y)=\{x_1,\ldots,x_r\}$ is finite, the local-degree formula is
$$
\boxed{\deg(f)=\sum_{j=1}^r\deg_{x_j}f}.
$$
Indeed <excision> identifies $H_n(S^n,S^n\setminus f^{-1}(y))$ with the direct sum of the local groups at the $x_j$. The global <fundamental class> maps to the vector of their local <orientation> generators, namely $(1,\ldots,1)$. Naturality of the map of pairs sends that vector to $\sum_j\deg_{x_j}f$ in the local group at $y$. The other route through the naturality diagram sends the global class by $f_*$ first and therefore gives $\deg(f)$. The map from the target <sphere>'s top homology to its <local homology> is an <isomorphism>, so the two integers agree. Empty fibres give degree zero by the same argument. Standard approximation by a homotopic smooth map permits the formula to be used with regular values when an original continuous map has no convenient finite fibre.