Sue Liu of Madras College, St Andrew's sent the solution to this problem. The locus of the point P is a straight line as the vertex Q of the right angled triangle PQR slides up the wall and the vertex R slides towards the corner.

Without loss of generality we can let the length of QR be 1 unit, and take a coordinate system with the origin at O and axes along OR and OQ. If PQR=α, where 0<α< 90 , then PQ=cosα and PR=sinα. Let QRO=θ where 0θ 90 . Then, from the right angled triangles PSQ and PTR, we have PRT=QPS=α-θ, and hence we can write down the coordinates of the point P.
x = cosαcos(α-θ) y = sinαcos(α-θ).

We see that
y x = sinαcos(α-θ) cosαcos(α-θ) =tanα.

and so P lies on the straight line y=xtanα.

The position (x,y) depends only on cos(α-θ), α being a constant, and θ a variable. The distance of the point P from O is given by
OP2 = x2 + y2 =cos2 (α-θ)(cos2 α+sin2 α)=cos2 (α-θ).

Hence OP=cos(α-θ) which is a maximum when cos(α-θ)=1, that is when α=θ. This occurs when OQPR is a rectangle as shown in the diagram.

We get an even simpler method of solution by using the fact that the angles QOR and QPR are both 90 degrees so that OQPR is a cyclic quadrilateral with PR as a chord. We have POR=PQR=α because these two angles are subtended by the same chord of the circle. This shows that

POR is constant and hence that the locus of P is the straight line y=xtanα.

What can you say about the locus of P if the triangle PQR is not a right angled triangle?