3

My first question is: How would one solve such problems (in general,squares+rectangles). What should be the general technique?How can this problem be reduced to a mathematical problem?

enter image description here

My second question is: When to be sure that we have counted all the squares in such problems?

Emma
  • 43
  • 5
  • 2
    I counted 40 of them. –  Jun 12 '14 at 14:02
  • @vadim123 Guess you didn't count the eight $\frac{1}{2}\times\frac{1}{2}$ squares. I got $40$ too. – M. Vinay Jun 12 '14 at 14:05
  • I get $40$ too. Is there someone with more squares? – Emma Jun 12 '14 at 14:12
  • 1
    if you look closer at the picture there are tons of squares in the background, dunno if you should count them too, perhaps it's a trick question – mm-aops Jun 12 '14 at 14:17
  • @mm-aops Even if that were actually the case, we should disregard it here as it's not math then. But good point. Also, I doubt even $2%$ would get it right by correctly counting all those tiny squares then. – M. Vinay Jun 12 '14 at 14:18
  • There are less than 625 such faint squares, because they are JPEG artifacts with block size 16x16 and the image is 403x403. There is also a residual background texture that one can imagine to be squares (with a fair amount of goodwill). My best estimate is 25 squares per JPEG block. –  Jun 12 '14 at 14:30

1 Answers1

2

A general procedure:

  • identify all line segments, taking them as long as possible. In the figure, there are 18 of them (10 forming the main grid, 8 forming the extra squares);

  • when a line segment has parts, consider all their decompositions, which count as a triangular number (a main grid line can be decomposed in 1 + 2 + 3 + 4 ways and a side of an extra square in 1 + 2 ways, in total, 10 x 10 + 8 x 3 = 124 chunks);

  • for every part of every segment, check if it is the side of a square; there are two possibilities each time.

  • finally take the total count and divide it by four (as you have counted every square four times).

A specific procedure:

A full grid of N² equal squares contributes $\frac{N(N+1)(2N+1)}6$ squares (pyramidal number).

In the given case, a 5x5 grid and two 2x2 grids for a total of $40$.

  • What if we include rectangles as well? – Emma Jun 12 '14 at 14:28
  • The general method can be modified to count all rectangles having the given side; this is done by systematic exploration of the perpendicular lines at both endpoints. And for the non-general approach, derive the formula for the rectangulo-pyramidal numbers... –  Jun 12 '14 at 14:34