4. Determine all ordered pairs $(x, y)$ of nonnegative integers that satisfy the equation
$$
3 x^{2}+2 \cdot 9^{y}=x\left(4^{y+1}-1\right) .
$$

This is a modified version of Problem N2 from the 2010 IMO shortlist.
Solution: The equation is equivalent to
$$
(3 x)^{2}+2 \cdot 3^{2 y+1}=3 x\left[2^{(2 y+1)+1}-1\right] .
$$

Letting $a=3 x$ and $b=2 y+1$, we have
$$
a^{2}+2 \cdot 3^{b}=a\left(2^{b+1}-1\right) \text {. }
$$

Case 1: $b=1$
We have $a^{2}-3 a+6=0$ which has no integer solution for $a$. Thus, there is no solution in this case.
Case 2: $b=3$
We have $a^{2}-15 a+54=0$, whose roots are 6 and 9 , both divisible by 3 . This case then has the solutions $(2,1)$ and $(3,1)$ for the original equation.
Case 3: $b=5$
We have $a^{2}-63 a+486=0$, whose roots are 9 and 54 , both divisible by 3. We get as additional solutions $(3,2)$ and $(18,2)$.

Case 4: $b \geq 7, b$ odd
It follows from (1) that $a \mid 2 \cdot 3^{b}$. Since $a$ is divisible by 3 , either $a=3^{p}$ for some $1 \leq p \leq b$ or $a=2 \cdot 3^{q}$ for some $1 \leq q \leq b$.
For the first case $a=3^{p}$, let $q=b-p$. Then we have
$$
2^{b+1}-1=a+\frac{2 \cdot 3^{b}}{a}=3^{p}+2 \cdot 3^{q} .
$$

For the second case $a=2 \cdot 3^{q}$, let $p=b-q$. Then we have
$$
2^{b+1}-1=a+\frac{2 \cdot 3^{b}}{a}=2 \cdot 3^{q}+3^{p} .
$$

In either case,
$$
2^{b+1}-1=3^{p}+2 \cdot 3^{q}
$$
where $p+q=b$. Consequently, $2^{b+1}>3^{p}$ and $2^{b+1}>2 \cdot 3^{q}$. Thus,
$$
\begin{aligned}
3^{p}b-\frac{2(b+1)}{3}=$ $\frac{b-2}{3}$. Therefore,
$$
\frac{b-2}{3}\frac{b-2}{3} \geq \frac{5}{3}$, then $r \geq 2$. Consequently, the right hand side of (2) is divisible by 9 . Thus, 9 divides $2^{b+1}-1$. This is true only if $6 \mid b+1$. Since $b \geq 7$, then $b \geq 11$. Thus, we can let $b+1=6 \mathrm{~s}$ for some positive integer $s$, and we can write
$$
2^{b+1}-1=2^{6 s}-1=4^{3 s}-1=\left(2^{s}-1\right)\left(2^{s}+1\right)\left(4^{2 s}+4^{s}+1\right) \text {. }
$$

Since $4^{s} \equiv 1 \bmod 3$, then $4^{2 s}+4^{s}+1=\left(4^{s}-1\right)^{2}+3 \cdot 4^{s}$ is always divisible by 3 but never by 9 . Furthermore, at most one of $2^{s}-1$ and $2^{s}+1$ is divisible by 3 , being consecutive odd numbers. Since $3^{r} \mid 2^{b+1}-1$, then either $3^{r-1} \mid 2^{s}-1$ or $3^{r-1} \mid 2^{s}+1$. From both cases, we have $3^{r-1} \leq 2^{s}+1$. Thus,
$$
3^{r-1} \leq 2^{s}+1 \leq 3^{s}=3^{\frac{b+1}{6}}
$$

Therefore,
$$
\frac{b-2}{3}-1<r-1 \leq \frac{b+1}{6}
$$
which implies $b<11$. However, there is no odd integer $b$ between 7 (included) and 11 (excluded) such that $6 \mid b+1$. There are then no solutions for this last case.
Therefore, the solutions $(x, y)$ of the given equation are $(2,1),(3,1),(3,2)$, and $(18,2)$.