A bunch of bits and pieces from a bunch of people:

Let us say we are trying to find the cardinality of the Group $G$. First, we select the group, $\bullet$ (unique up to isomorphism) such that for any other group, there is a unique arrow in and out of $\bullet$. Now, we select a group $\mathbb{Z}$, unique up to isomorphism, such that it only has two idempotent homomorhpisms, and it admits at least two morphisms to any other group besides $\bullet$ (thanks Todd Trimble). Now we find how many morphisms there are from $\mathbb{Z}$ to $G$ (special thanks to Steven Gubkin). This is $|G|$.

## Proof

The group $\bullet$ is the trivial group. Now, the group $\mathbb{Z}$ of integers satisfies the properties above via the proof here. Now, for any other group $H$ which satisfies the properties, we know that there is a nontrivial morphism $f : H \rightarrow \mathbb{Z}$. Now the image of $f$ will be a group of integers, and so must be multiples of a given integer $n$ (which won't be zero since $f$ is nontrivial.) We can take a map from this to all the integers, so that we can turn $f$ into a surjection $\bar f$. Now, we make a morphism from $\mathbb{Z}$ to $H$, $i$, such that $i(1) = x$ for some $\bar f(x) = 1$.

Since $\bar f(i(n)) =\bar f(x+x+x+\dotsb)=\bar f(x)+ \bar f(x)+ \bar f(x)+\dotsb=1+1+1+\dotsb=n$, $\bar f \circ i = id_\mathbb{Z}$. This means that $i \circ \bar f$ is idempotent, and since $i(\bar f(x)) = x$, it is not the zero morphism. Since $H$ has only two idempotents (the zero morphism and $\operatorname{id}_H$), and $i \circ \bar f \neq 0$, $i \circ \bar f = id_H$. (Thanks Slade.) Therefore they are inverses. Therefore we can select $\mathbb{Z}$ up to isomorphism.

For each element of $G$, $x$ we make a morphism from $\mathbb{Z}$ to $G$, $h$, such that $h(n) = n * x$. Also, for any morphism $h: \mathbb{Z} \rightarrow G $, $h(n) = n * h(1)$, where $h(1)$ is an element of $G$. Therefore, the morphisms between the integers and $G$ are in one to one correspondence with the elements of $G$. Therefore $|\operatorname{Hom}(\mathbb{Z}, G)| = |G|$.

$\square$

16more comments