Solution (source code)

= Solution

Let $U=\operatorname{Spec}A$ and $V=\operatorname{Spec}B$ be <affine open subschemes> of the <separated scheme> $X$. Its <diagonal morphism> is a <closed immersion>
$$
\Delta:X\hookrightarrow X\times_{\operatorname{Spec}\mathbb Z}X.
$$
Restricting this <closed immersion> to the <open subscheme> $U\times_{\operatorname{Spec}\mathbb Z}V$ identifies its inverse image with $U\cap V$. Hence
$$
U\cap V\hookrightarrow U\times_{\operatorname{Spec}\mathbb Z}V
=\operatorname{Spec}(A\otimes_{\mathbb Z}B)
$$
is a <closed immersion>. A <closed subscheme> of an <affine scheme> is an <affine scheme>, so
$$
\boxed{U\cap V\text{ is an affine open subscheme of }X.}
$$
The argument iterates to every finite intersection of <affine open subschemes>. The empty intersection of two disjoint charts causes no exception: the empty <scheme> is $\operatorname{Spec}(0)$.