Solution (source code)

= Solution

The <Chinese remainder theorem> says that for pairwise coprime positive integers $m_i$, the map
$$
\mathbb Z/(m_1\cdots m_r)\mathbb Z
\longrightarrow\prod_i\mathbb Z/m_i\mathbb Z
$$
is a bijection. For two <moduli>, choose $u,v$ with $um+vn=1$; then
$$
x=b,um+a,vn
$$
has residues $a$ modulo $m$ and $b$ modulo $n$. Uniqueness follows because the difference of two solutions is divisible by both coprime <moduli>, hence by their product. Induction proves the general case.

The two given congruences are compatible modulo $\gcd(6,8)=2$, and checking modulo $\operatorname{lcm}(6,8)=24$ gives
$$
x\equiv10\pmod{24}.
$$

Write $d=2^r3^sm$ with $(m,6)=1$. Use the Chinese remainder theorem to choose
$$
a\equiv0\pmod{2^r},\qquad 2a\equiv1\pmod{3^sm},
$$
$$
3b\equiv1\pmod{2^r},\qquad b\equiv0\pmod{3^sm}.
$$
Then $4a^2+9b^2\equiv1$ modulo each of the pairwise coprime factors $2^r$, $3^s$, and $m$, hence modulo $d$.