Henry Ernest Dudeney/Modern Puzzles/128 - Lines and Squares/General Solution

by : $128$

 * Lines and Squares

General Solution
With $n$ straight lines we can make as many as:


 * $\dfrac {\paren {n - 3} \paren {n - 1} \paren {n + 1} } {24}$ squares if $n$ is odd


 * $\dfrac {\paren {n - 2} \paren {n - 1} n } {24}$ squares if $n$ is even.

Proof
Suppose with $n$ lines, we create a rectangular grid with $a$ columns and $b$ rows.

Further suppose that $a < b$.

We can add an extra column and remove a row simultaneouly without changing the total number of lines $n$.

By adding one more column, we create:
 * $b$ squares with side length $1$;
 * $b - 1$ squares with side length $2$;
 * $b - a + 1$ squares with side length $a$.
 * $b - a + 1$ squares with side length $a$.

The number of new squares this process adds will be:

By removing a row now, we remove:
 * $a + 1$ squares with side length $1$;
 * $a$ squares with side length $2$;
 * $1$ square with side length $a + 1$.
 * $1$ square with side length $a + 1$.

The number of squares this process removes will be:

The net change of the number of squares is:

Therefore for the same $n$, the closer the number of rows and columns are, the more squares we would create.

For even $n$, we would have $\dfrac n 2$ vertical lines and horizontal lines each.

This creates a square grid with side length $\dfrac n 2 - 1$.

The number of squares with side length $1$ is $\paren {\dfrac n 2 - 1}^2$.

The number of squares with side length $2$ is $\paren {\dfrac n 2 - 2}^2$.

...

The number of squares with side length $\dfrac n 2 - 1$ is $1^2$.

Hence there would be:

Now suppose we create a rectangle with $n + 1$ lines.

By adding an extra column (or row), we would create:
 * $\dfrac n 2 - 1$ more squares with side length $1$;
 * $\dfrac n 2 - 2$ more squares with side length $2$;
 * $1$ more square with side length $\dfrac n 2 - 1$.
 * $1$ more square with side length $\dfrac n 2 - 1$.

The total number of squares will now become:

By doing the substitution $n \to n - 1$, we obtain the formula for odd $n$:
 * $\dfrac {\paren {n - 3} \paren {n - 1} \paren {n + 1} } {24}$