You are given a grid of integral values.
Ex:
0 1 2 3 4 5
6 7 8 9 0 1
1 3 5 7 9 1
5 6 5 6 5 6
In addition to its width and height.
You are asked to find the sum of the elements that fall inside the domain. The domain is defined as a list of rectangles that can overlap. Each rectangle is defined by four values: col (starting column), row(starting row), cols (width in columns), rows (height in rows).
An example domain to sum over for the above grid is:
Rectangle 1: 0 0 2 2
Rectangle 2: 1 1 2 2
The above two rectangles overlap on the single cell at coordinates (1, 1). The element in there should be added to the sum [strike]twice[/strike]
once. The sum would then be: 0 + 1 + 6 + 7 + 8 + 3 + 5 = 30.