There is a 5×5 grid in front of you. You have to fill 25 squares with only 0 and 1.
But, every neighboring square's (that is not diagonally adjacent) number's product has to be 0.
How many possible grids there are?
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.
in the first solution can you give details how you used the recursive relation to compute X5(0). i am getting stuck. honestly i thought it is an impossible to solve this using elementary techniques. i thought a computer code is the only option. it is nice solution.
thanks i got it. nice solution.
in the second solution can you explain the last step.
From a combinatorial perspective, when one views filling the grid with ones and zeros, one can treat it as summation of (5,k) as k approaches 5. This yields 2^5=32 . This is a stark contrast to your 13. Could you please account for the discrepancy? Thanks.
Log in to reply
Remember, we cannot have two adjacent squares both containing 1 , so while there are 2 5 = 3 2 ways of filling a row with 0 s and 1 s, corresponding to all integers from 0 to 3 1 , we are not allowed numbers whose binary expansion contains consecutive 1 s. Thus the number 1 9 = 1 0 0 1 1 2 is not allowed. There are only 1 3 numbers between 0 and 3 1 whose binary expression does not contain successive 1 s; they are 0 (no 1 s), 1 , 2 , 4 , 8 , 1 6 (one 1 ), 5 , 9 , 1 0 , 1 7 , 1 8 , 2 0 (two 1 s) and 2 1 (three 1 s).
This is an example of a 5 × 5 grid:
You can make a C - programme to solve this problem. (If you run the programme and type "5 5" and wait for just a few seconds, you can get the answer.)
Try it!!!
The phrasing of the problem is extremely unclear, even misleading. I suggest Mark Henning's re-phrasing.
The condition is equivalent to stating that no two ones can be adjacent. Focusing on rows, there are 13 different rows possible: A=00000, B=00001, C=00010, D=00100, E=00101, F=01000, G=01001, H=01010, I=10000, J=10001, K=10010, L=10100, M=10101.
Two rows can occur directly above each other if they have no ones in common (for the programmers: a bitwise logical AND should result in 0).
Pattern A can have all 13 neighbours (ABCDEFGHIJKLM) directly below or above it, B can have 8 (ACDFHIKL), C can have 10 (ABDEFGIJLM), D can have 9 (ABCFGHIJK), E can have 6 (ACFHIK), F can have 10 (ABCDEIJKLM), G can have 6 (ACDIKL), H can have 8 (ABDEIJLM), I can have 8 (ABCDEFGH), J can have 5 (ACDFH), K can have 6 (ABDEFG), L can have 6 (ABCFGH), M can have 4 (ACFH).
We start filling the grid by choosing a pattern for the middle row
Problem Loading...
Note Loading...
Set Loading...
Each row can be filled in one of 1 3 different ways, each way representing one of the binary numbers in S = { 0 , 1 , 2 , 4 , 8 , 1 6 , 5 , 9 , 1 0 , 1 7 , 1 8 , 2 0 , 2 1 } .
If a particular row is represented by the number x ∈ S , then then next row can be represented by the number y ∈ S provided that the bitwise AND x & y of x and y is 0 . Thus we can obtain the recursive formulae X 0 ( x ) X m ( x ) = 1 = y ∈ S , x & y = 0 ∑ X m − 1 ( y ) x ∈ S , m ≥ 1 where X m ( x ) is the number of ways in which an ( m + 1 ) × 5 array can be filled with no adjacent 1 s, given that the first row is represented by the number x ∈ S . It is a simple matter to calculate that X 5 ( 0 ) = 5 5 4 4 7
Another way of seeing this result is to note that the first, third and fifth rows can be chosen freely from S . If the first, third and fifth rows are x , y , z ∈ S respectively, then the second row could be any u ∈ S such that u & x = u & y = 0 , and hence such that u & ( x ∣ y ) = 0 , where x ∣ y is the bitwise OR of x and y . If we define N ( x , y ) = ∣ ∣ { u ∈ S ∣ ∣ u & ( x ∣ y ) = 0 } ∣ ∣ x , y ∈ S then the desired number of grid numberings is x , y , z ∈ S ∑ N ( x , y ) N ( y , z ) = y ∈ S ∑ ( x ∈ S ∑ N ( x , y ) ) 2 = 5 5 4 4 7