I have a problem when I need to combine small squares into large rectangles. Let's say I have a 2D grid filled with random 1 and 0:
1 0 1 1 0 1 0 1 1 1 0 1 0 1 1 0 1 0 1 1 0 0 1 0 0
1 represent areas that are filled, and I draw them to show the way down the line as squares. However, for this problem, I need to first match them with the rectangles. In the show example, 1 in the upper left corner ā
1 1
can be connected to a rectangle.
I think this should be enough to explain what I need. However, it is preferred that a particular square is not used in more than one rectangle. Also, this should not be the best case with the fewest rectangles, just the best case with fewer rectangles. 1x1 rectangles are also allowed, which will facilitate the task.
Any insight into where I could start, or even a solution would be appreciated.
If you want to know the cause of this problem, Iām working on a level creator for the game Iām working on, and I want to reduce the number of vertices. I thought I would start with squares because they will be simple, but even that scares my mind.
Thanks for taking the time to read!
source share