An interesting problem

Dirk Koopman djk at
Wed Jan 3 21:32:52 GMT 2007

On Wed, 2007-01-03 at 14:03 +0000, Paul Orrock wrote:
> Hi,

> I have a 2d table of data with each cell having a positive or negative 
> value. By summing a range of data which is x columns by y rows anywhere 
> in the table it will come up with a positive or negative figure. What I 
> need to find is which range yields the highest positive result. The 
> range can be any size and have its first cell at any point in the table.

Are actually trying to find the area (of whatever size) that represents
the greatest, for want of a better term, "density". 

Are you trying to actually determine the "area" that gives the greatest
number and its dimensions (rather than a number representing the largest
possible)? Is the size of the area fixed (or is there some other

There could be more than one solution if the grid that you are searching
through is big enough.

If the area required is fixed (or otherwise determinate), I would have
thought that doing a pass through the grid looking for the indexes of
the largest number(s) and then doing trial solutions putting that index
in all the positions of the area should be close.  

More information about the mailing list