\noindent Let $P=\{1,2,3,\dots,n\}$ be the set of $n$ people, where the people are designated by some pre-assigned numbering (shirt number, face recognition, what have you). Let $C=\{1,2,3,\dots,n\}$ be the set of $n$ possible hat colors, where the colors are designated by some pre-assigned number (wavelength, aesthetic value, what have you). The hat assignment, then, is an arbitrary function $f:P\to C$.

\noindent Define the ``guessing function" $G:P\to C$ as follows:
\[ \forall k \in P\;\text{{\huge .}}\quad G(k) = \left[k-\left(\sum_{i\in P\setminus\{k\}} f(i)\right)\right] \!\!\!\!\!\!\!\mod n\]
That is, each person $k\in P$ looks at the hats on everyone else's heads, evaluates those colors as values, finds the sum, subtracts that value from his/her own {\it person number}, and evaluates this modulo $n$.\vspace{0.5cm}

\noindent Let's prove why this "guessing function" yields a person that correctly guesses their own hat color. (In fact, we can show this is the {\it only} person who guesses correctly!) Consider the sum of all of the hat colors, reduced modulo $n$:
\[ S = \left[\sum_{i\in P} f(i)\right]\!\!\!\!\!\!\mod n \]
This number satisfies $1\leq S\leq n$. Consider the person whose assigned number is this number, person $S$.

\noindent What does that person guess as their hat color? According to the guessing function, we find
\begin{align*}
G(S) &= \left[ S-\left(\sum_{i\in P-\{S\}} f(i)\right)\right]\!\!\!\!\!\!\mod n \\
&= \left[S-\bigl(S-f(S)\bigr)\right]\!\!\!\!\!\!\mod n\\
&= \left[f(S)\right]\!\!\!\!\!\!\mod n\\
&= f(S)
\end{align*}
because $1\leq f(S)\leq 100$.

\noindent Thus, person $S$ guesses their hat color, $f(S)$!

\noindent To see why this is the unique correct guesser, consider $k\in P$ with $k\neq S$.

\[ G(k) &= \left[k-\left(S-f(k)\right)\right]\!\!\!\!\!\!\mod n = [(f(k)+k-S)]\!\!\!\!\! \mod n \]

\noindent To ensure this is equal to $f(k)$, we require that $(k-S)$ is 0 modulo $n$, or that $(k-S)$ is a multiple of $n$. Since both $k$ and $S$ satisfy $1\leq k,S\leq n$, there is no way this can happen unless they are equal, yielding $k-S=0$. (To get $k-S=-n$, say, we would need $S\geq n+1$, and to get $k-S=n$, say, we would need $k\geq n+1$.)

\noindent This shows that this guessing function yields a (unique) person who correctly guesses their own hat color!