In an m x n grid of squares there are m+1 lines in one direction and n+1 in the other. In choosing a rectangle out of those, you're choosing one upper line, one lower line, a left line and a right line, so there are C(m+1,2)*C(n+1,2) such rectangles.
The following program has a function, rects, to evaluates the number of rectangles in an a x b grid of squares, and uses it to try all the possible combinations of square grid size (up to 31 squares on a side, as beyond that there are more than three digits in the number of individual squares in the grid).
DECLARE FUNCTION rects! (a!, b!)
FOR a = 1 TO 31
orig = rects(a, a)
FOR i = 1 TO a / 2
new1 = rects(a, i)
new2 = rects(a, a - i)
IF 3 * (new1 + new2) = 2 * orig THEN
PRINT USING "## ###### ## ###### ###### ###### ######"; a; orig; i; new1; new2; new1 + new2; (new1 + new2) * 3 / 2
END IF
NEXT i
NEXT a
FUNCTION rects (a, b)
ap = a + 1: bp = b + 1
rects = ap * bp * a * b / 4
END FUNCTION
The resulting table shows:
sq cut first second total total * 3/2
size rects placement rects rects
2 9 1 3 3 6 9
3 36 1 6 18 24 36
8 1296 2 108 756 864 1296
27 142884 6 7938 87318 95256 142884
So Susan's larger square was a 27x27 square of little squares, and was cut below the 6th row of squares, into a 6x27 rectangle of little squares, with 7938 rectangles that could possibly be formed from the gridlines and a 21x27 rectangle of little squares, with 87,318 visible rectangles. The total of 95,256 is 2/3 of the original 142,884 rectangles that could be seen with the 27x27 array of little squares.
The other lines above pertain in the same way to the bonus question.
Adapted from Enigma No. 1452, by Susan Denham, New Scientist 21 July 2007.
|