Inspired by certain puzzles on Flow Free: Warps.
Background
We all know that L-triominos can't tile the 3x3 board, and P-pentominos can't tile the 5x5 board. But the situation changes if we allow the board to wrap around in both dimensions:
L-triominos can tile 3x3 toroidal grid
The 3rd tile wraps around through all four edges.
┌┌─┐┐││3 ┌─┤└─┐││2 ││└─┬─┘│1 │└───┘┘
P-pentominos can tile the 5x5 toroidal grid
The 5th tile wraps around through all four edges.
┌┌───┬─┐┐│││┌─┘│└─┐│ 1 │2 │├─────┤││ 3 │││┌─┴─┬─┤││││└─┬─┘│╵│ 4 │5└└─────┘┘
Note that, in both cases, wrapping around in only one dimension doesn't allow such tiling.
In case the Unicode version is hard to read, here is the ASCII version:
3 2 31 2 21 1 35 1 1 2 51 1 1 2 23 3 3 2 23 3 4 4 55 4 4 4 5
Challenge
Given a polyomino and the size (width and height) of the toroidal grid, determine if the polyomino can tile the toroidal grid. The polyomino can be flipped and/or rotated.
A polyomino can be given in a variety of ways:
- A list of coordinates representing each cell of polyomino
- A 2D grid with on/off values of your choice (in this case, you cannot assume that the size of the grid defining the polyomino matches that of the toroidal grid)
The output (true or false) can be given using the truthy/falsy values in your language of choice, or two distinct values to indicate true/false respectively.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
The polyomino is given as the collection of #
symbols.
Truthy
# (singleton, a.k.a. monomino)5x7 (or any size)--------## (domino)4x3 (or any even size)--------### (L-triomino)3x3 (as shown above)--------##### (P-pentomino)5x5 (as shown above)--------## ## (Z-tetromino)4x4 (left as an exercise to the reader)--------##### (V-pentomino)5x5--------#### # ### (a polyomino larger than the grid is possible)4x4--------### ### ### (single polyomino can cover the entire grid, and can wrap multiple times)3x3
Falsy
## (domino)3x5 (or any odd sizes)--------####1x8--------# #### (U-pentomino)5x5