Reputation: 41
I did a search on whether this has been asked before but I could not find any similar question. This is more of a algorithmic question and is not confined to any particular programming language. So, my question is as follows.
Data given:
Problem: Calculate size(width and height) of each block. i.e., calculate (w0, h0), (w1, h1), ..., (wn-1, hn-1).
I feel this problem can be generalized to a space of any dimension.
Upvotes: 2
Views: 91
Reputation: 51316
I see now that you are looking for a way to partition the grid into rectangular blocks having given upper-left corners. However, in general there is still more than one way to do this. E.g. given the 3 upper-left corners A, B and C in the 4x4 grid on the left below, either of the two sets of blocks to its right solves the problem:
A.B. AaBb AaBb
.... aabb aabb
C... Ccbb Cccc
.... ccbb cccc
You can make a larger grid from as many copies of this grid as you like. A grid made from k copies (and thus using 3k blocks) will have 2^k distinct solutions.
Also, a particular problem instance need not have any solution. For example, at least one grid square is left uncovered by the problem instance on the left:
A. Aa A.
.B .B aB
Upvotes: 1