How many grid squares are crossed by the diagonal




















For more brainteasers and puzzles for kids, subscribe to Double Helix magazine! This reminds me of a puzzle my uncle gave to me 50 years ago. I found the puzzle too difficult, but when my uncle showed me the method, I realised the solution was easy to find but fiddly.

The puzzle: There is a rectangular room 30 units long, 12 units wide and 12 units high. A huntman spider is in the centre of the end wall, one unit up from the floor. A fly sleeps in the centre of the opposite end wall, one unit down from the ceiling. What is the shortest distance the spider can run in order to catch the fly?

He cut it in such a way that a straight line could be drawn between the two points. Then he measured the line! By posting a comment you are agreeing to the Double Helix commenting guidelines.

Notify me of follow-up comments by email. Notify me of new posts by email. This site uses Akismet to reduce spam. We count only "rectangles", not the squares which are special cases of rectangles. Remember, only rectangles where the length is longer than the width. Again, the best way to creep up on a solution is to start out with the small size squares and see where it leads you. For a 2x2 square, we have a total of 4 possible rectangles, each 1x2. For the 3x3 square, we can find 12 1x2 rectangles, 6 1x3 rectangles, and 4 2x3 rectangles for a total of For the 4x4 square, we can find 24 1x2's, 16 1x3's, 8 1x4's, 12 2x3's, 6 2x4's, and 4 3x4's for a total of 70 rectangles.

For the 5x5 square, we get 40 1x2's, 30 1x3's, 20 1x4's, 10 1x5's, 24 2x3's, 16 2x4's, 8 2x5's, 12 3x4's, 6 3x5's, and 4 4x5's.

Did you notice anything as you looked through these numbers? Lets put them into a tabular form. Along side each nxn square will be the number of rectangles identified at the top of the column. The number of 3 square wide rectangles in each case is equal to the number of 2 square wide rectangles in the previous case.

The total number of rectangles in a square of nxn squares is equal to the sum of the 1 square wide rectangles for each rectangle from the 2x2 up to and including the nxn one being considered. Re: formula for grids A big thankyou to all who replied Cheers, Barry. Someone New member. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Learn more. Number of squares crossed by a diagonal Ask Question. Asked 6 years ago. Active 9 months ago. As we have already observed, the number S of the crossed squares is 1 more than that:. It's a good idea now to check this formula by counting for a few additional cases of relatively small M and N.

In preparation for the next step, pay attention to those M and N, for which the formula fails, i. It's hard to miss the point that this happens when M and N have non-trivial common divisors, i. It is easy to generalize again. How many internal grid points lie on the diagonal? But such a shift would have added 1 count at every grid point on the diagonal. Taking this into account we arrive at another formula:.

Further generalization would be to consider the configuration where the grid lines are not distributed evenly. In this case, the formula 1 is still true as long as no grid points lie on the diagonal, whereas 2 loses its significance. From this point of view, 1 which is applicable in a more broad context, is more general than 2.



0コメント

  • 1000 / 1000