How many distinct squares can be formed by connecting dots in the diagram above?
As a bonus, can you generalize to an n × n lattice, or a n × m lattice?
Inspired by Maria Kozlowska's similar problem, called "Triangles on a Christmas tree".
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Cam you explain that solution?
@Nathan Ramesh Can you ellaborate?
Log in to reply
It is self-explanatory.
Answer should be 1x1 + 2x2 + 3x3 + 4x4 =30
Log in to reply
No the answer is not 30 you should also count the tilted square it is a dot grid not a square grid hence tilted squares can be obtained.
There are n − x ) ( m − x ) ways to pick an orthogonal side with side x in the grid.
Apart from the square itself, there are x − 1 tilted squares that fit snugly inside. (Consider the possible locations for a vertex of the tilted square on the left side of the orthogonal square.)
Thus the number of possibilities, assuming that n ≤ m , is S n m = x = 1 ∑ n ( n − x ) ( m − x ) x . In this case, n = m = 5 and it is easy to evaluate the sum: S 4 = 4 2 ⋅ 1 + 3 2 ⋅ 2 + 2 2 ⋅ 3 + 1 2 ⋅ 4 = 1 6 + 1 8 + 1 2 + 4 = 5 0 .
More generally, if n = m the sum can be written as S n = 1 2 1 ( n − 1 ) n 2 ( n + 1 ) = 6 1 ( n 2 2 ) .
Brute force but nice. I'm indebted to people on codegolf. The square is invariant under 90-degree rotations about its centre, and multiplication of a point in the complex plane by i amounts to a 90-degree rotation in that plane about the origin. Packaging those facts yields a nice solution.
Here's a good explanation of the general solution .
Problem Loading...
Note Loading...
Set Loading...
I evaluated the sum k = 1 ∑ n − 1 k ( n − k ) 2 which evaluates to 6 1 ( 2 n 2 ) , begging me to believe that there is a nice bijective solution as well.