Chapter 20
How Do You Like Them Rectangles?
Riddler Express
In the staircase of three rectangles below, find the height marked with a question mark.

Solution
The three rectangles share a left edge, so their widths grow by the marked overhangs. The top rectangle has area and height , hence width . The middle rectangle juts out further and the bottom one juts out another , so the bottom rectangle is wide. Its area is , so the unknown height is The bottom rectangle is exactly as tall as the top one. (The middle area, , is extra information, not needed for the height.)
The computation
Chain the widths down the staircase and divide the bottom area by the bottom width.
top_width = 24 / 4 # top area / top height
bottom_width = top_width + 3 + 2 # add the two marked overhangs
print(44 / bottom_width) # 4.0 in
Riddler Classic
Four rectangles are arranged inside a frame inches wide and inches tall, as below. Three of their areas are given; find the area of the shaded rectangle.

Solution
Let the shaded rectangle be wide and tall. Along the bottom it sits beside the -rectangle to fill the -inch width, both of height , and up the left side it sits below the -rectangle to fill the -inch height, both of width : Subtracting the second from the first clears the term, giving . Substituting into the first equation yields The two roots describe two candidate figures, and the top-right -rectangle settles which is real: with height it has width , and starting at it must fit inside the -inch frame, . The root needs width and overflows; the root needs only and fits. So the shaded area is
The computation
Solve the two area equations symbolically and keep the root whose top-right rectangle fits inside the -inch width.
import sympy as sp
x, y = sp.symbols('x y', positive=True)
sols = sp.solve([sp.Eq((14 - x) * y, 45), sp.Eq((11 - y) * x, 32)], [x, y])
for xv, yv in sols:
fits = xv + 34 / (11 - yv) <= 14 # top-right rectangle fits?
print(xv, yv, "area", xv * yv, "fits" if fits else "overflows")