Solution (source code)

= Solution

Let $Y$ be the <affine variety> with <coordinate ring> $A$. Its principal opens $D(f_i)$ cover $Y$ because $\sum_i g_if_i=1$. On $X_{f_i}$, the <localization of global sections on a principal open> identifies its <coordinate ring> with $A_{f_i}$, giving an <isomorphism>
$$
\phi_i:X_{f_i}\xrightarrow{\sim}D(f_i)\subseteq Y.
$$
On an overlap the two maps are induced by the same elements of $A$, or equivalently by the same identification with $A_{f_if_j}$, so they agree. Glue them to $\phi:X\to Y$. The inverses agree on the overlaps as well and glue to its inverse. At a <closed point> $P$, this is the map corresponding to the evaluation <ring homomorphism> $A\to k$, $a\mapsto a(P)$. This proves the <cohomological criterion for affineness> by an explicit global <isomorphism>.