Let a 3D grid, like a chessboard, have an extra dimension. Now let's say that I have a certain number of cubes in this grid, each cube occupies 1x1x1 cells. Let them say that each of these cubes is an element.
What I would like to do is replace / merge these cubes into larger boxes, occupying any number of cells along the X, Y and Z axes, so that the resulting number of boxes is as small as possible, while preserving the overall appearance. "
This is probably unclear, so I will give a 2D example. Say I have a 2D grid containing several squares occupying 1x1 cells. The letter represents the cells occupied by this element, and each element has a different letter from the others. In the first example, we have 10 different elements, each of which occupies 1x1x1 cells.
+---+---+---+---+---+---+
| | | | | | |
+---+---+---+---+---+---+
| | A | B | C | D | |
+---+---+---+---+---+---+
| | E | F | G | H | |
+---+---+---+---+---+---+
| | | K | L | | |
+---+---+---+---+---+---+
| | | | | | |
+---+---+---+---+---+---+
This is my input. Now I can optimize it, i.e. Reduce the number of elements while still occupying the same cells in several possible ways, one of which might be:
+---+---+---+---+---+---+
| | | | | | |
+---+---+---+---+---+---+
| | A | B | B | C | |
+---+---+---+---+---+---+
| | A | B | B | C | |
+---+---+---+---+---+---+
| | | B | B | | |
+---+---+---+---+---+---+
| | | | | | |
+---+---+---+---+---+---+
Here, instead of 10 elements, I have only 3 (i, A, B and C). However, it can be optimized even more:
+---+---+---+---+---+---+
| | | | | | |
+---+---+---+---+---+---+
| | A | A | A | A | |
+---+---+---+---+---+---+
| | A | A | A | A | |
+---+---+---+---+---+---+
| | | B | B | | |
+---+---+---+---+---+---+
| | | | | | |
+---+---+---+---+---+---+
Here I have only two elements: A and B. It is as optimized as possible.
, , - , , , , , 3D!
? , , , . !