Consider the following 8 × 8 grid. Count the total number of squares that do not contain the square with the red star.
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.
Stunning and that is an understatement!
A really awesome solution.
Log in to reply
It just became a lot awesomer-- see my edited solution :)
Log in to reply
Incredible! Really really amazing.
Oh my god! You are awesome :O.
Number of 1×1 squares that contains the red star = 1×1 = 1
Number of 2×2 squares that contains the red star = 2×2 = 4
Number of 3×3 squares that contains the red star = 3×3 = 9
Number of 4×4 squares that contains the red star = 3×4 = 12
Number of 5×5 squares that contains the red star = 3×4 = 12
Number of total 1×1 squares = 8×8 = 64
Number of total 2×2 squares = 7×7= 49
Number of total 3×3 squares = 6×6 = 36
Number of total 4×4 squares = 5×5 = 25
Number of total 5×5 squares = 4×4 = 16
Note:- Here we dont count any 6×6, 7×7 and 8×8 grids, because all of them would contain the red star which we dont want.
Number of 8×8 squares that does not contain the red star = 64 - 1= 63
Number of 7×7 squares that does not contain the red star = 49 - 4= 45
Number of 6×6 squares that does not contain the red star = 36 - 9= 27
Number of 5×5 squares that does not contain the red star = 25 - 12= 13
Number of 4×4 squares that does not contain the red star = 16 - 12= 4
So, total number of squares that does not contain the red star = 6 3 + 4 5 + 2 7 + 1 3 + 4 = 1 5 2
@Ashish Siva - Same!
How come there are more squares that doesn't contain the red star that squares in the grid (64)? I mean, I saw that the red star is being contained in one square, therefore the squares that doesn't contain the red star are 63
Log in to reply
The number of squares that contains the red star are not only 1×1 squares, they can even be 2×2 and 3×3 and 4×4........ 8×8 the question is not so simple. ;)
Perfect. I was expecting a more general solution; I mean, not the particular analysis, but to generalize the counting process without consider possible each case.
Log in to reply
Thanks, will think about that as soon as I get back :)
Problem Loading...
Note Loading...
Set Loading...
General solution
Suppose we have an n × n grid, with the red star at position ( a , b ) .
Consider a square of size k × k , and let the left corner of this square have coordinates ( x , y ) . The square fits entirely on the grid if 1 ≤ x ≤ n − k + 1 ; 1 ≤ y ≤ n − k + 1 ; the number of squares for which this is the case is ( n − k + 1 ) 2 . Writing k ′ = n + 1 − k , the total number of squares is then k = 1 ∑ n ( n − k + 1 ) 2 = k ′ = 1 ∑ n ( k ′ ) 2 = 6 1 n ( n + 1 ) ( 2 n + 1 ) .
The square contains the red star if moreover a − k + 1 ≤ x ≤ a ; b − k + 1 ≤ y ≤ b . Combining the two conditions, max ( 1 , a − k + 1 ) ≤ x ≤ min ( n − k + 1 , a ) ; max ( 1 , b − k + 1 ) ≤ y ≤ min ( n − k + 1 , b ) . The number of squares for which this is the case is R k = ( min ( n − k + 1 , a ) − max ( 1 , a − k + 1 ) + 1 ) ⋅ ( min ( n − k + 1 , b ) − max ( 1 , b − k + 1 ) + 1 ) = ( min ( n − k − a + 1 , 0 ) + min ( a , k ) ) ⋅ ( min ( n − k − b + 1 , 0 ) + min ( b , k ) ) .
Without loss of generality...
The expression for the sum ∑ R k will not be easy to simplify. It becomes a bit simpler if we can assume, without loss of generality, that 1 ≤ b ≤ a ≤ ⌈ 2 1 n ⌉ . Then R k = ⎩ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎧ k ⋅ k k ⋅ b a ⋅ b ( n − k + 1 ) ⋅ b ( n − k + 1 ) ⋅ ( n − k + 1 ) k ≤ b b ≤ k ≤ a a ≤ k ≤ n + 1 − a n + 1 − a ≤ k ≤ n + 1 − b k ≥ n + 1 − b Note that, if we write k ′ = n + 1 − k etc., a symmetric picture appears: R k = ⎩ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎧ k ⋅ k k ⋅ b a ⋅ b k ′ ⋅ b k ′ ⋅ k ′ k ≤ b b ≤ k ≤ a a ≤ k , k ′ b ≤ k ′ ≤ a k ′ ≤ b Thus the sum becomes k = 1 ∑ n R k = 2 ⋅ k = 1 ∑ b k 2 + 2 ⋅ k = b + 1 ∑ a k ⋅ b + k = a + 1 ∑ n − a a ⋅ b = 3 b ( b + 1 ) ( 2 b + 1 ) + b ( a ( a + 1 ) − b ( b + 1 ) ) + ( n − 2 a ) a b = ( n + 1 − a ) a b − 3 1 ( b − 1 ) b ( b + 1 ) . This is the number of squares that contains a red star.
Applying it to the given values
n = 8 , a = 4 , and b = 3 . Thus there are 6 1 n ( n + 1 ) ( 2 n + 1 ) = 6 1 ⋅ 8 ⋅ 9 ⋅ 1 7 = 2 0 4 squares in total, of which ( n + 1 − a ) a b − 3 1 ( b − 1 ) b ( b + 1 ) = 5 ⋅ 3 ⋅ 4 − 3 1 ⋅ 2 ⋅ 3 ⋅ 4 = 6 0 − 8 = 5 2 contain a star. The answer, then, is 2 0 4 − 5 2 = 1 5 2 .