# Given N blocks, find the number of unique shapes in a NxN block

Constraints: The blocks must be adjacent to each other. i.e. A pair of blocks must have a common edge or vertex. Any shapes that are formed by flipping or rotating or mirroring should be considered to be the same shape.

By manual inspection, for example, For N=2, there are 2 unique shapes in a 2x2 grid

[][]

[]
[]


For N=3, there are 5 unique shapes in a 3x3 grid

[][][]

[][]
[]

[]
[][]

[]  []
[]

[]
[]
[]


I can find the total number of shapes using the combination formula, nCr

For r=2 and n=2x2=4, we get 4C2 = 6 shapes (4+2)

For r=3 and n=3x3=9, we get 9C3 = 84 shapes (6+16+16+8+2) + 36 non-adjacent

Need help in finding out mathematically or algorithm-wise,

• how to identify non-adjacent blocks
• how to identify mirror patterns
• how to identify rotating/flippable patterns

Similar questions were asked in the following links but I wasn't able to extrapolate any concrete solutions.

• By your stated rules, there are $5$ unique shapes for $N=2$: You omit the single block, the $L$ shape, and the full grid. Did you mean the queivalent of "How many distinguishable length-$N$ non-self-intersecting paths are there in an $N\times N$ square grid such that for all $k$, the $k+1$-st vertex on the path is adjacent or diagonally adjacent to the $k$-th entry? – Mark Fischler Jul 19 '16 at 20:37
• I don't understand yet, some shapes seem to be missing in the list for $3$. – André Nicolas Jul 19 '16 at 20:55