Proved myself wrong with this set of data:

lrds 2 6 7 4 1 7 7 NB. largest rectangle within data set (at that stage only matrix output)
2 6 7 4 1 7 7
0 1 1 1 0 1 1                    NB. 14 vs 12 (hmm)

So, if I'd stick with that approach, it isn't the *longest *block, but maybe largest product of block length and minimum height.
Even that would need some coding to extract different block lengths ...

-M

At 2017-06-20 16:07, you wrote:

Both of those are valid answers.

The problem is simply to determine the largest area.

Thanks,

--
Raul


On Tue, Jun 20, 2017 at 11:58 AM, 'Pascal Jasmin' via Programming
<[email protected]> wrote:
> is the answer to your example, 6x2 or 4x3?



> ________________________________
> From: Raul Miller <[email protected]>
> To: Programming forum <[email protected]>
> Sent: Tuesday, June 20, 2017 11:30 AM
> Subject: [Jprogramming] largest rectangle problem



> Something I stumbled over today.


> If we have a series of bars of varying height, what's the largest

> rectangle that can be drawn over the bars without covering any empty

> space.


> For example:


>    '*'#"0~2 6 7 4 1 7

> **

> ******

> *******

> ****

> *

> *******


> I'll post a solution later, and I'll be interested in seeing if it's

> basically the only obvious approach or if there's a variety of good

> approaches. (I have reason to believe, though, that there's a better

> way than what I came up with.)


> Thanks,


> --

> Raul

> ----------------------------------------------------------------------

> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to