Solution (source code)

= Solution

The <classification theorem for closed combinatorial surfaces> states that the <geometric realization> of every <closed combinatorial surface> is <homeomorphic> to exactly one of the following:

* The <sphere> $S^2$.
* An <orientable> <surface> $\Sigma_g$ formed as a <connected sum of surfaces> of $g\geq1$ copies of the <torus> $T^2$.
* A <nonorientable surface> $N_k$ formed as a <connected sum of surfaces> of $k\geq1$ copies of the <real projective plane> $\mathbb{RP}^2$.

With $\Sigma_0=S^2$, the complete distinguishing data are <orientability> and the <Euler characteristic>:
$$
\chi(\Sigma_g)=2-2g,\qquad \chi(N_k)=2-k.
$$
Here $\chi(K)=V-E+F$, where $V,E,F$ count the <vertices of a simplicial complex>, <edges>, and triangles of a finite <triangulation>. Thus two such <connected> closed <surfaces> are <homeomorphic> if and only if they have the same <orientability> and <Euler characteristic>. In particular $N_1$ is the <real projective plane> and $N_2$ is the <Klein bottle>. Every listed type admits a finite <triangulation>. For disconnected finite <closed combinatorial surfaces>, apply the theorem to each of the finitely many <connected components>; the resulting unordered collection of types determines the <homeomorphism> type.