There are 11 ways to tile a 3 × 4 rectangle with dominoes:
Note that rotations and reflections are considered distinct.
How many ways are there to tile a 5 × 6 rectangle with dominoes?
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.
Good detailed analysis of the problem.
The number of ways to tile a domino board of dimension m × n is given by:
j = 1 ∏ 3 k = 1 ∏ 3 ( 4 cos 2 ( 5 + 1 π j ) + 5 cos 2 ( 6 + 1 π k ) )
Evaluating, we get 1183.
Got a proof?
Log in to reply
You can visit the wikipedia page on domino tilings. It contains a link to the research paper with a proof.
since constraints are very small, we can just use recursive backtracking :p assume we are at (x,y), if we can put a horizontal domino, put it. then try a vertical domino, then backtrack. a[5][6] corresponds to the current board. code: https://ideone.com/gLBPuD (only ran for 0,1 s on local machine)
I am completly mind blown by some of the solution posted here, especialy @Ivan Koswar 's one. It mad me realize how amazing humans are. I saw this problem two years ago, i had no idea how to tackle it, yesterday i decided to give it a try and what do you know i solved it ! (well, my solution is far from efficient), this is the reason why i love this website !
Here is my solution (for any N x M grid):
EDIT: cleaning, work with any domino dimension (N D x M D).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
Problem Loading...
Note Loading...
Set Loading...
The answer is 1183.
The trick is to realize that this problem is effectively asking for the number of perfect matchings on the 5 × 6 square grid graph . (A domino corresponds to an edge chosen in the matching.) Moreover, the square grid graph is planar . Finding the number of perfect matchings in a planar graph can be computed efficiently (in O ( ∣ V ∣ 3 ) time) using FKT algorithm . Thus this is just an easy application of the FKT algorithm. (Other matching algorithms are discussed here .)
The FKT algorithm works as follows; with an input of a planar graph G :
In general graphs, step 2 is not efficiently computable (unless P = # P ). In planar graphs, it can be computed efficiently (see the Wikipedia article; it adds orientations freely unless when it is forced to orient in a way to give a face the required odd number of edges). However, we know our graph already; we can just compute step 2 ourselves. The orientation I use is simple:
Given that orientation, it's easy to hard-code the matrix. We can simply compute the determinant and find the square root of the resulting matrix. Since the grid is 5 × 6 , we have 5 ⋅ 6 = 3 0 vertices, so it should run quickly enough. Python 3 code follows:
This code can even work for the original problem, a 9 × 1 2 grid. (It runs in approximately 10 seconds.) The answer is 1937528668711. I decided to use only 5 × 6 ; it's just beyond brute force approach, but it's still small enough that precision errors don't matter yet. (With 9 × 1 2 , precision errors might matter. In Python, I used the
fractions
library above, to make sure that they are not present; however, using other languages, it's very likely that people will use the data typedouble
, which is prone to precision errors.)