18: Using some convenient triangles

one gets the formula

Note that this tells us how long a beam can fit at a specific angle, but this does not guaranteee that this beam will fit at different angles. Thus, if we want to carry this beam completely through the bend, we need a length that will fit in all position. This means that the optimal length is actually the minimal of the lengths that we calculated above.

Thus one needs to minimize l(a) over the set M = (0,π/2), use the standard algorithm.

Next hint
Answer