Quantcast
Viewing all articles
Browse latest Browse all 35

Test a polyomino against Conway criterion

Background

Conway criterion is a method to test if a given polygon can tile (i.e. cover without overlapping) an infinite plane. It states that a polygon can tile the plane if the following conditions are met:

  • The given polygon does not have any holes in it.
  • It is possible to choose six consecutive1 points \$A,B,C,D,E,F\$ on its perimeter, so that
    • The boundary part of \$A\$ to \$B\$ must be equal to that of \$E\$ to \$D\$ in its size, shape, and orientation;
    • Each of the boundary parts \$BC\$, \$CD\$, \$EF\$, and \$FA\$ must have 180-degrees rotational symmetry; and
    • At least 3 out of the six points must be distinct from each other.

1) By consecutive, the six points must appear in the given order if you walk around the shape in one direction (either CW (clockwise) or CCW (counter-clockwise)). A boundary part between two consecutive points may contain zero, one, or multiple line segments.

If all the conditions are met, the given shape can tile the plane using only translation and 180-degree rotation. However, failing the condition doesn't mean the piece can't tile the plane. This happens when the tiling involves 90-degree rotations and/or reflections, or the tiling does not use 180-degree rotation at all.

The following is one example that satisfies Conway criterion:

Image may be NSFW.
Clik here to view.
enter image description here

with its plane tiling:

Image may be NSFW.
Clik here to view.
enter image description here

Task

Given a polyomino without holes as input, determine if it satisfies Conway criterion.

You can take the input in any sensible ways, including but not limited to

  • a 2D grid;
  • a list of coordinates of the cells;
  • a list of coordinates on the boundary (including non-vertices or not);
  • a list of steps starting from some point on the perimeter in NSEW notation, ...

If you use the input format that describes the perimeter (e.g. the last two formats above), you can assume that the input (the sequence of points or steps on the perimeter) is given in certain direction (either CW or CCW), but you cannot assume that it starts at any certain position.

Standard rules apply. The shortest code in bytes wins.

Test cases

The test cases are given as 2D grid, where O is a part of the polyomino and . is an empty space.

True

the example aboveOO........OOOOOOOOOOOOOOOOOOOO....OOOOOO....OOOOOO....OOOOOO....OOOOOO....OOOOOOthe F pentomino.OOOO..O.one possible set of points:  A---E=F  |   |+-++-+|   |B-+ D  | |+-COOO.O.OOE---D-C|     |F +-++-+| | |   |+-+ A---Ba nonomino that can tile with or without 180 degrees rotation.O...OOOOOO..OO..O..can you spot ABCDEF here? (hint: two points out of ABCDEF are not on the vertices)OOOO....OOOO..OO.O...O..OOOOhow about this? (hint: AB and DE are zero-length)...OOOO.OO.OO...O..OOO..OOOO......OOOOOO..OO....

False

can tile the plane, but needs 90 deg rotation.OOO.OO.OOcannot tile the plane at allOOOOO...O.OOOOO.can tile with only translation, but not with 180 degrees rotation...O.OOOOOO...OO

Viewing all articles
Browse latest Browse all 35

Trending Articles