Solution (source code)

= Solution

Treat the ladder as a uniform slender <rigid body>. While both contacts remain imposed, its <centre of mass> is $(l\sin\theta,l\cos\theta)$, with <speed> $l|\dot\theta|$. Its central <moment of inertia> is $m(2l)^2/12=ml^2/3$. Adding translational and rotational <kinetic energy> gives
$$
K=\frac12ml^2\dot\theta^2+\frac12\frac{ml^2}{3}\dot\theta^2
=\frac23ml^2\dot\theta^2.
$$
Taking the floor as zero <gravitational potential energy>, the <Lagrangian>, <conjugate momentum> and <Euler-Lagrange equation> are
$$
\boxed{L=\frac23ml^2\dot\theta^2-mgl\cos\theta,\qquad
p_\theta=\frac43ml^2\dot\theta,\qquad
\ddot\theta=\frac{3g}{4l}\sin\theta.}
$$
The positive sign is appropriate: gravity increases the angle from the vertical. These are the constrained equations of a <frictionless sliding ladder>. Real wall contact is unilateral: a wall cannot pull the ladder. Once the computed <normal force> would become negative, the two-contact model ceases to apply; the question explicitly assumes that contact persists.