Index a Polyomino

POLYOMINO_INDEX, a C++ library which is given a matrix defining a polyomino P, and determines a correspondingly shaped matrix which contains an index for each nonzero entry in P.

The indexing scheme starts at the upper left corner, and proceeds by rows.

For instance, the matrix representing P might be:

  1 0 1 1
  1 1 1 0
  0 1 1 0
in which case, the index matrix PIN would be:
  1 0 2 3
  4 5 6 0
  0 7 8 0


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


POLYOMINO_INDEX is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

PENTOMINOES, a C++ library which provides some utilities for manipulating pentominoes.

POLYOMINO_CONDENSE, a C++ program which cleans up a matrix that represents a polyomino by setting all nonzero entries to 1, and removing initial and final rows and columns of zeros.

POLYOMINO_EMBED, a C++ library which is given matrices defining a region R and a polyomino P, and determines the number of possible embeddings of the polyomino into the region, and the translations necessary to achieve them.

POLYOMINO_ENUMERATE, a C++ library which enumerates chiral, fixed and free polyominoes up to a moderate order.

POLYOMINO_LP_WRITE, a C++ program which writes an LP file describing a (binary) integer programming problem related to the tiling of a region R by copies of polyomino shapes, with possible reflections and rotations.

POLYOMINO_TRANSFORM, a C++ program which applies reflection and rotation transforms to the matrix that represents a polyomino.


  1. Solomon Golomb,
    Polyominoes: Puzzles, Patterns, Problems, and Packings,
    Princeton University Press, 1996,
    ISBN: 9780691024448

Source Code:

Last revised on 30 April 2018.