I need to find the number of the possible combinations of tilings of a 4xN board, with L shaped tiles that are 3x2. The tiles can be rotated freely. Any solution? Thanks.
-
- Is it allowed to mirror the L-shaped tile?
- Are all tiles the same or they have for example different colour?
- Can there be empty gaps or whole the area has to be filled?
– Hume2 May 10 '20 at 18:48 -
@Hume2. Thanks for the answer! 1) Yes, it's allowed. 2) All the tiles are the same. 3) The whole area has to be filled. – andreasaracino May 10 '20 at 18:54
-
One more question: Do mirrored or rotated sollutions count as the same or not? – Hume2 May 10 '20 at 18:55
-
@Hume2 Well, I think that if it is symmetrical, the mirror or rotation doesn't count as a solution. If it isn't symmetrical then it counts – andreasaracino May 10 '20 at 18:57
-
And when it's not symetrical, does the mirrored or rotated variant count as a different sollution? – Hume2 May 10 '20 at 18:58
-
If it isn't symmetrical then it counts. – andreasaracino May 10 '20 at 18:59
1 Answers
I have a sollution which involves backtracking.
Order the squares in the grid like this: $$ \begin{matrix} 1 & 5 & 9 & \ldots \\ 2 & 6 & 10 & \ldots \\ 3 & 7 & 11 & \ldots \\ 4 & 8 & 12 & \ldots \\ \end{matrix} $$
Figure out all the ways to occupy the least square (the one with the smallest number I just assigned), there might be more ways to do that. You can also check it you don't create a gap which would be then impossible to fill to speed the algorithm. Iterate over all the possible ways to occupy the least square and for each way calculate the number of possibilities to tile the rest. After that, sum these numbers up and you get the result.
You will also need to cache the results because you will be filling the same space many times again. The cache should grow by $O(N)$ because there are only constantly many ways the untiled area can border with the tiled area. The border will never exceed the size 3×4 because the ordering ensures that the gaps in the border must be filled before the border moves to the right.
No combination will be explored twice because each combination is defined by the sequence of rotations of tiles in the least square.
Pseudo-code:
int Tile(shape_of_uncovered_region) {
if (shape_of_uncovered_region is in cache) then return extract_from_cache(shape_of_uncovered_region)
sum = 0
least_square = find the unoccupied square with the least number
for (new_tile in (all ways to occupy least_square by a new tile)) {
if (is obvious that it will be impossible to finish tiling) then continue //optional
sum += Tile(shape_of_uncovered_region without new_tile)
}
put (shape_of_uncovered_region, sum) into cache
return sum
}
- 2,264
-
-
I mean the square which has the smallest number I have assigned at the beginning. – Hume2 May 10 '20 at 19:57
-
thanks. If that's not an issue, could you provide a clear pseudo code of the algorithm? Because you know, I'm not good at math – andreasaracino May 10 '20 at 20:00
-
I gave you a pseudo-code. You will need to realise yourself how to represent the stuff because this depends on the programming language etc... – Hume2 May 10 '20 at 20:10
-