Given a 128-bit lookup table describing a hexagonal cellular automaton filter, decide whether applying the filter twice always equals applying it once.
Medium4SimulationBrute forceBit manipulationImplementationNo attempts yetTime limit8sMemory limit512 MBConsider monochrome images made of hexagonal pixels, each one colored black or white. Because a pixel is a hexagon, every pixel has exactly six neighbors, the six pixels that share an edge with it.
Filtering is an operation that decides the new color of a pixel from the colors of the pixel itself and its six neighbors. Here are three filters.
The first filter colors a pixel white when all six of its neighbors are white, and leaves the color unchanged otherwise.

Applying it to every pixel at the same time performs noise canceling, which removes isolated black pixels.
The second filter colors a pixel white when all six of its neighbors are black, and leaves the color unchanged otherwise.

Applying it to every pixel at the same time performs edge detection, which keeps only the borders of filled areas.
The third filter ignores every other neighbor and takes the color of the pixel directly below.

Applying it to every pixel at the same time shifts the whole image up by one pixel.
Applying noise canceling or edge detection twice to any image gives exactly the same result as applying it once. A filter with that property is idempotent. The shift filter is not idempotent, because every application moves the image up by one more pixel.
The image covers the whole hexagonal grid, so any arrangement of colors on a finite group of pixels appears in some image.
Decide whether a given filter is idempotent.
The input has several datasets, and the number of datasets is less than 100. Each dataset is one line holding a filter as a string of 128 characters with no spaces.
c0c1⋯c127
Each ci is '0' (black) or '1' (white) and gives the color the filter outputs for a pixel when the binary representation of the pixel and its six neighbors is i. The bits sit around the center pixel like this.

Bit 3 is the center pixel the filter is applied to, bit 6 is the pixel above it, bit 0 the pixel below it, bit 5 the upper left neighbor, bit 4 the upper right neighbor, bit 2 the lower left neighbor, and bit 1 the lower right neighbor. The value i is i=∑j=06bitj×2j, where bitj is 0 when the matching pixel is black and 1 when it is white.
The last line of the input contains a single '#'.
For each dataset, print yes on its own line if the filter is idempotent, and no otherwise.