On Facebook every now and then someone will post a “How many squares in this image?” riddle, and in the comments the answers will range from acurate to ignorant to outlandishly stupid. Today I came across this image:
Thousands of comments with answers from 6 to 18, so I set out to write a little PHP and Javascript program to count and visualize the squares.
For those not sure of the terminology:
- all the shapes in this image are rectangles, i.e. their corners are all 90º;
- however, not all of them are squares, i.e. equilateral rectangles, with four identical sides.
Also, while there are only four shapes in this image which are themselves squares, combinations of two or more shapes also form squares and will be counted as such.
So here we go:
rect1
rect2
square1
square2
rect3
rect4
square3
square4
rect5
square5
square6
As this demonstrates, there are:
- 6 single, simple squares (1-6),
- 5 composite squares made up of two to four single squares 7-11), and
- finally the whole image is also a square (12),
which makes a total of twelve squares.