[Math] How to arranged two or more different colored blocks in all possible ways

combinatorics

Is any algorythem that can arrange two or more different blocks in all possible ways.. in series (rows and columns.)?

If I have two colored(red and blue) blocks and I try to arranged in one possible way… see the example image.

enter image description here

please give me such solution that can arrange all possible ways to arrange blocks.
If we have "N" number of block than How many ways to generate design from "N" blocks in all possible ways.

Thanks in advanced

Best Answer

I think you are looking for a way to encode a tiling. If you have no constraints at all, and you have $n$ places to put tiles of $b$ different colors, then the easiest encoding scheme is to represent a tiling as a base $b$ number with $n$ digits.

More explicitly, label your places with numbers $0$ through $n-1$, and label your colors $0$ through $b-1$. Then the coloring where tile $i$ is colored color $c_i$ is represented by the number $(c_{n-1}c_{n-2}\cdots c_2 c_1 c_0)_b=\sum c_i b^i$. If you want to enumerate the colorings, just list out the numbers between $0$ and $b^n-1$.