12.49 Find all integer solutions $(x, y, z)$ of the equation $2^{x}+3^{y}=z^{2}$.
(German Federal Mathematics Competition, 1987)
Let $(x, y, z)$ be a set of integer solutions to the equation
$$
2^{x}+3^{y}=z^{2}
$$

Assume $x$ or $y$ is negative, then
$$
0<2^{x}+3^{y}<1
$$
which contradicts the fact that $z^{2}$ is a positive integer. Therefore, we only need to find the integer solutions where $x \geq 0$ and $y \geq 0$.

(1) When $x=0$, from (1) we have
$$
\begin{array}{c}
1+3^{y}=z^{2} . \\
3^{y}=(z-1)(z+1) .
\end{array}
$$

Since 3 is a prime number, then
$$
\left\{\begin{array}{l}
z-1=3^{t} \\
z+1=3^{s}
\end{array}\right.
$$

where $t<s, \quad t+s=y$.
Since
$$
\begin{array}{c}
3^{s}-3^{t}=2 \\
3^{t}\left(3^{s-t}-1\right)=2
\end{array}
$$

and 2 is a prime number, $3^{t} \neq 2$, thus $3^{t}=1$, which means $t=0$. From $3^{s}-1=2$ we get $s=1$.
Therefore,
$$
y=1, \quad z=2 .
$$

(2) When $y=0$, from (1) we have
$$
2^{x}=(z-1)(z+1) .
$$

Thus,
$$
\left\{\begin{array}{l}
z-1=2^{t}, \\
z+1=2^{s} . \quad t<s, \quad t+s=x .
\end{array}\right.
$$

Eliminating $z$ gives
$$
2^{s}-2^{t}=2
$$

Similarly,
$$
2^{t}\left(2^{s-t}-1\right)=2 \text {. }
$$

Thus,
$$
\begin{array}{ll}
t=1, & s=2 . \\
x=3, & z=3 .
\end{array}
$$

(3) When $x$ and $y$ are both positive integers,
we first prove that $x$ and $y$ are both even.
Assume $x$ is odd, let $x=2 p+1, p$ be a non-negative integer, from (1) we have
$$
2^{2 p+1}+3^{y}=z^{2}
$$
$$
2(3+1)^{p}+3^{y}=z^{2}
$$

Since
$$
(3+1)^{p} \equiv 1(\bmod 3),
$$

then
$$
2(3+1)^{p}+3^{y} \equiv 2(\bmod 3) .
$$

However, a number of the form $3 k+2$ is not a perfect square, so $2(3+1)^{p}+3^{y}$ is not a square number, while $z^{2}$ is a square number, which is impossible.
Therefore, $x$ is even, and let $x=2 p$.
Assume $y$ is odd, let $y=2 q+1$, where $q$ is a non-negative integer, from (1) we have $4^{p}+3(8+1)^{q}=z^{2}$.
Since $\quad(8+1)^{4} \equiv 1(\bmod 4)$,

then
$$
4^{p}+3(8+1)^{q} \equiv 3 \quad(\bmod 4) \text {. }
$$

However, a number of the form $4 k+3$ is not a perfect square, so $4^{p}+3(8+1)^{q}$ is not a square number, while $z^{2}$ is a square number, which is impossible.
Therefore, $y$ is even, and let $y=2 q$.
At this point, equation (1) becomes
$$
\begin{array}{c}
2^{2 p}+3^{2 q}=z^{2}, \\
3^{2 q}=\left(z-2^{p}\right)\left(z+2^{p}\right),
\end{array}
$$

thus
$$
2^{p+1}=3^{s}-3^{t}=3^{t}\left(3^{s-t}-1\right) .
$$

Therefore, $t=0$, thus $\quad z=2^{p}+1$.
On the other hand,
$$
\begin{array}{c}
2^{2 p}=\left(z-3^{q}\right)\left(z+3^{q}\right), \\
2^{2 p}=\left(1+2^{p}-3^{q}\right)\left(1+2^{p}+3^{q}\right) .
\end{array}
$$

Thus, we can set
$$
\begin{array}{l}
1+2^{p}-3^{q}=2^{u} \\
1+2^{p}+3^{q}=2^{v}
\end{array}
$$

where $0 \leqslant u<v$, and $u+v=2 p$.
Subtracting the two equations gives
$$
2^{v}-2^{u}=2^{u}\left(2^{v-u}-1\right)=2 \cdot 3^{4} .
$$

Thus,
$$
2^{u}=1 \text { or } 2 .
$$

When $2^{u}=1$, we have
$$
\begin{array}{c}
1+2^{p}-3^{q}=1 \\
2^{p}=3^{q}
\end{array}
$$

which is impossible.
Therefore, $2^{u}=2, u=1$, and
$$
2^{p}=3^{q}+1 \text {. }
$$

If $p$ is odd, then $p=2 k+1$, the left side of the equation
$$
\text { left side }=2^{p}=2 \cdot 4^{k}=2 \cdot(3+1)^{k} \equiv 2(\bmod 3),
$$
$$
\text { right side }=3^{q}+1 \equiv 1(\bmod 3) \text {, }
$$

which is impossible, so $p$ is even.
Let $p=2 b$, then we have
$$
\begin{array}{l}
\left(2^{b}\right)^{2}=3^{q}+1, \\
3^{q}=\left(2^{b}-1\right)\left(2^{b}+1\right) .
\end{array}
$$
$$
\text { thus } \quad 2^{b}-1=1, \quad b=1, \quad p=2, \quad q=1 \text {. }
$$
$$
\text { Therefore } \quad x=4, y=2, z=5 \text {. }
$$

In summary, the equation has six sets of integer solutions:
$$
\begin{array}{l}
(0,1,2),(3,0,3),(4,2,5) \\
(0,1,-2),(3,0,-3),(4,
\end{array}
$$