KA-0047Counting by position (sliding window)
5 points, difficulty 3 of 3Level 5–6about 135sOn a 4 by 4 board, how many aligned squares of any size are there, counting 1 by 1, 2 by 2, 3 by 3 and 4 by 4?
Hints
Take them one at a time. The first gives nothing away.
1A nudge
Do each size separately, largest first.
2The strategy
For a square of side k on a 4 by 4 board, the top-left corner can sit in 5 minus k columns and 5 minus k rows. Work out that count for each size and add.
3The full solution
Size 1: 4 x 4 = 16. Size 2: 3 x 3 = 9. Size 3: 2 x 2 = 4. Size 4: 1 x 1 = 1. Total 16 + 9 + 4 + 1 = 30.
Solution
The reliable way
Take the sizes one at a time. A square of side k has its top-left corner in (5 - k) columns and (5 - k) rows. Side 1 gives 16, side 2 gives 9, side 3 gives 4, side 4 gives 1. Adding: 16 + 9 + 4 + 1 = 30. The transferable idea: count by size, and let the sliding range shrink as the shape grows.
The elegant way
The total is the sum of the first four square numbers, which is 30 - the same shape of answer on any n by n board.
Why this is on the test: Counting by size is the habit that stops a student missing the middle sizes, and this is the cleanest place to practise it.