Solution (source code)

= Solution

The unrotated squares have a gap $d>a$, so their facing exclusion layers do not overlap. Rotation can bring them into contact even though their centers remain fixed. The strongest <depletion force> comes from \b[parallel faces in contact over a long shared length], rather than a corner-to-corner contact.

Let $r=\ell+d$. Rotate both squares through the same angle $\theta$ relative to their original orientation. Their center displacement has a face-normal component $r\cos\theta$ and a tangential component $r\sin\theta$. Face contact requires
$$
\boxed{\cos\theta_* =\frac\ell r,\qquad
\theta_*=\pm\arccos\frac\ell{\ell+d}\simeq\pm\sqrt{\frac{2d}{\ell}}.}
$$
The contacting faces overlap for length
$$
L=\ell-r|\sin\theta_*|=\ell-\sqrt{r^2-\ell^2}\simeq\ell-\sqrt{2\ell d}.
$$
These two mirror-related orientations, together with equivalent square rotations, maximize the leading overlap area when $a<d\ll\ell$. A small <polymer> gap sacrifices overlap width without a compensating leading increase in contact length.