A fence 7 feet tall runs parallel to a tall building at a distance of 3 feet from the building.

What is the length of the shortest ladder that will reach from the ground over the fence to the wall of the building?

If we let

y = length of ladder
x = distance from fence to foot of ladder
then using similar triangles

√(x^2+7^2)/x = y/(x+3)
That is,
y = (x+3)√(x^2+49)/x
dy/dx = (x^3-147)/(x^2√(x^2+149))
dy/dx = 0 when x = ∛147
so y = 13.75 ft

extra credit: How high up the building does the ladder reach?

Looks like this problem is just a bit too tough for the AI to handle, so let

a human do it.

Make a sketch of a side view of the situation.
Draw the ladder, and from the point of contact of the ladder with the top
of the fence, draw a vertical and a horizontal.
You now have two similar triangles, label the angle that the ladder makes
with the ground as θ, label the two parts of the ladder L1 and L2, and L the length of the ladder so that L = L1 + L2

From the top right-angled triangle: cosθ = 3/L1 ---> L1 = 3secθ
From the bottom right-angled triangle: sinθ = 7/L2 ----> L2 = 7cscθ

L = L1 + L2 = 3secθ + 7cscθ
dL/dθ = 3secθ tanθ - 7 cscθ cotθ = 0 for a min of L
3secθtanθ = 7cscθcotθ
secθtanθ/(cscθcotθ) = 7/3
...
tan^3 θ = 7/3
θ = appr 52.98°

now you can find L1 and L2, so you go ahead and finish it.
Let me know what you get