# In how many different ways can a 9-panel comic grid be used?

While writing my answer to Why does “Watchmen” use the 9-panel grid? I used this picture to indicate the many ways it can be divided into groups (which may be used for the panels of a comic, as was the case in “Watchmen”):

Afterwards, it has been pointed out to me in a comment that there are some combinations that are not present in this picture:

The $$8181$$ variations on the $$99$$ panel grid in that diagram don’t exhaust the possibilities — there are certainly many others. For example, this one is one of the many that aren’t shown there.

Another comment says that the 9-panel grid can be used in $$40964096$$ different ways:

The are $$1212$$ interior borders, each of which can be included or excluded in a particular layout. That’s $$212=40962^{12} = 4096$$ possibilities.

A two-page spread treats two $$3×33 \times 3$$ grids as a single $$6×36 \times 3$$ grid with $$2121$$ internal borders, for $$2,097,1522,097,152$$ possibilities.

How can I calculate that? I tried the following:

• There a $$33$$ ways to group the third row.
• That leaves us with $$44$$ panels in 2nd and 3rd rows. I count $$44$$ ways to group those.
• The $$1212$$ combinations so far must be multiplied by $$44$$ (because I can rotate them) and by $$22$$ (because I can mirror them).

This gives me $$9696$$ variations. The picture above has $$8181$$; the comment said there are $$40964096$$.

Is there a layman-friendly geometrical solution? I’m not really interested in a precise value (a lot is enough for me), I’m more interested in the technique or a rule. Is there a general rule for a n-by-n grid?

To clarify: panels must be rectangular, i.e. they must be formed by merging some of the $$99$$ panels horizontally or vertically:

Suppose we create a layout by deleting borders between the panels of a
$3\times 3$ grid, as has been suggested at various times.
But let’s put some restrictions on which borders we can delete so that no non-rectangular panels are possible, but all layouts with rectangular panels are possible.

Consider the four border segments that meet at a single vertex in the
$3\times 3$ grid. Label these segments
$N, E, S, W$ in clockwise order starting from the top.
If you delete three of these segments and leave one intact, you end up with a panel with a “crack” in it, not a rectangle. There are $4$ forbidden arrangements of this kind.
If you delete two “adjacent” segments such as $N, E,$ you end up with a panel that has a “concave” corner, again not a rectangle. That gives us another $4$ forbidden arrangements.

But any of the other $16 - 4 - 4 = 8$ combinations of border segments around a common vertex can occur in a layout consisting purely of rectangles.
Call these the permitted combinations.

It seems “obvious” (though maybe not so obvious how to prove) that as long as all four vertices in the interior of the grid have permitted combinations of edges, the layout will consist only of rectangles.

Actually counting the combinations that can occur together is more complicated. It’s not $8^4,$ because there are many ways the choice of combination of edges at a vertex can be restricted by the combinations at the adjacent vertices.

To enumerate the possibilities, consider the edges that might or might not exist around the central square of the $3\times 3$ grid.

Case 1. All four edges exist. So the $NE$ vertex of this square has at least $W$ and $S$ edges; there are $3$ permitted combinations of the the other two edges. Similarly, there area $3$ permitted combinations at each of the other three vertices of the central square. This gives us $3^4=81$ possible layouts.

Case 2. Three edges exist. To begin with, we have $4$ choices of which edge to delete.
Then, at each of the two vertices adjacent to the deleted edge, there are exactly $2$ permitted combinations of edges.
(For example, if we delete the $E$ edge of the central square but not its other three edges, the $NE$ vertex has edge $W$ but not edge $S$; it must therefore have edge $E$ but edge $N$ is optional.)
At each of the other two vertices, there are still $3$ permitted combinations. Altogether, there are
$4 \times 2^2 \times 3^2 = 144$ layouts of this kind.

Case 3. Two opposite edges exist, the other two are deleted.
There are $2$ ways to choose which pair of edges to delete around the central square; at each of the four vertices there are then $2$ permitted combinations of edges. Altogether there are $2\times 2^4 = 32$
layouts of this kind.

Case 4. Two adjacent edges exist, the other two are deleted.
There are $4$ ways to choose which pair of edges to delete around the central square. At the vertex with two edges there are then $3$ permitted combinations of edges; at each of the two vertices adjacent to that, there are $2$ permitted combinations of edges; and at the fourth vertex (the one with two adjacent deleted edges already) all four edges must be deleted. Altogether there are $4\times 3 \times 2^2 = 48$
layouts of this kind.

Case 5. One edge exists. We have $4$ choices of which edge this will be.
Then, at each of the two vertices adjacent to the remaining edge, there are exactly $2$ permitted combinations of edges.
The other two vertices already have two adjacent edges deleted, so they each must have all four edges deleted. Altogether, there are
$4 \times 2^2 = 16$ layouts of this kind.

Case 6. No edges exist around the central square. There is only one layout with this property, the one consisting of a single panel.

so there are $322$ possible layouts.