Monday, May 16, 2011

counting squares contd...

As a continuation of the previous post on counting squares, here is the update. Only two of my friends commented their solutions to this simple problem and here are two approaches.

lets assume a board where n = 6. drawing a line would make the board look like this.

   +----+----+----+----+----+----+
   | \\ |    |    |    |    |    |
   +----+----+----+----+----+----+
   |    | \\ |    |    |    |    |
   +----+----+----+----+----+----+
   |    |    | \\ |    |    |    |
   +----+----+----+----+----+----+
   |    |    |    | \\ |    |    |
   +----+----+----+----+----+----+
   |    |    |    |    | \\ |    |
   +----+----+----+----+----+----+
   |    |    |    |    |    | \\ |
   +----+----+----+----+----+----+

what i think is the the "indian" geeky way of looking at it is to eliminate the  other half and visualize the same board as

   +----+
   | \\ | number of squares = 1
   +----+----+
   |    | \\ | number of squares = 2
   +----+----+----+
   |    |    | \\ | number of squares = 3
   +----+----+----+----+
   |    |    |    | \\ | number of squares = 4
   +----+----+----+----+----+
   |    |    |    |    | \\ | number of squares = 5
   +----+----+----+----+----+----+
   |    |    |    |    |    | \\ | number of squares = 6
   +----+----+----+----+----+----+

and so people arrive with the standard n(n+1)/2 which people remember, thanks to the caning by their high school math teacher for not remembering the sum of natural numbers series up to n :)

but there is a simple way of looking at it
1. the number of squares slashed by the diagonal is n.
2. total number of squares = n^2
3. so remaining squares = (n^2) - n which is equally divided between the two halves
4. so total squares not slashed = [(n^2) - n] / 2 = M
5. so if you want to include the number of squares slashed by the diagonal as
well, then its M + n

I took the first way to get the equation, but that is probably the harder way to do math. a thoughtful layman would come up with the second method first time and is backed by observation.
 

Cheers
Ghanashyam

No comments:

Post a Comment