Tuesday 2 April 2013

Diagonal Problem

Problem: find the number of squares crossed by the diagonal on a (m x n) grid.
Plan: 1) draw lots of examples to make the relationship between diagonal and grid more noticeable
         2) write common findings across examples
         3) study the differences between examples
         4) make a hypothesis
         5) test hypothesis and try to disprove it
         6) look for special cases and divide the results
carry out plan:
           m = columns
           n = rows
           t = number of squares crossed
     
 this is the table of results:
         m / 1 / 2 / 2 / 2 / 3 / 3 / 3 / 4 / 4 / 4 / 5 / 5 / 5
         n / 1 / 2 / 3 / 4 / 3 / 4 / 5 / 4 / 5 / 6 / 5 / 6 / 7
         t / 1 / 2 / 4 / 4 / 3 / 6 / 7 / 4 / 8 / 8 / 5 / 10 / 11

special case: when ever m = n  then t = m = n 
when ever m or n is even: then t = 2 ( the smallest of m or n)
 when ever both m and n are odd: then t = 2( the smalles of m or n) + 1

in conclusion there is a special case where m = n then t = m = n, the general case is where either m or n is even then t is two times the smallest between m and n. If both m and n are odd then t is two times the smallest between m and n plus one.

No comments:

Post a Comment