Assume a boolean array:
1111 1111 1110 1111 1001
Now you need to find a way to arrange the smallest rectangles of any size to achieve this shape. So, for example, you will find this:
+-++ | |+ | | +-++ + +
Where + is the angle of the rectangle and |, are the borders of the rectangle.
What I thought about this starts with the maximum possible rectangle, checking if there is a place in the array in which it can be placed, where each element of the array covered by the rectangle is true. If such a place exists, the rectangle will be added to the list. Then we check the left space of the array, if there is another spot in which the rectangle is placed, then reduce the size of the rectangle and repeat the process with the remaining space until the size is 0.
This should give good results, since we always start with large rectangles, which of course we can use less, which, in turn, means that we use small amounts of rectangles.
However, this is just a concept that I was thinking about and not yet implemented. This seems rather inefficient, so I was wondering if there are any known fast algorithms to achieve this?
language-agnostic algorithm cell
Marc mรผller
source share