I think that I would approach it using ;. 3 to create results such as this
3 4 <;. 3 '*'#"0~2 6 7 4 1 7
┌────┬────┬────┬────┬───┬──┬─┐
│** │* │ │ │ │ │ │
│****│****│****│*** │** │* │ │
│****│****│****│****│***│**│*│
├────┼────┼────┼────┼───┼──┼─┤
│****│****│****│*** │** │* │ │
│****│****│****│****│***│**│*│
│****│*** │** │* │ │ │ │
├────┼────┼────┼────┼───┼──┼─┤
│****│****│****│****│***│**│*│
│****│*** │** │* │ │ │ │
│* │ │ │ │ │ │ │
├────┼────┼────┼────┼───┼──┼─┤
│****│*** │** │* │ │ │ │
│* │ │ │ │ │ │ │
│****│****│****│****│***│**│*│
├────┼────┼────┼────┼───┼──┼─┤
│* │ │ │ │ │ │ │
│****│****│****│****│***│**│*│
├────┼────┼────┼────┼───┼──┼─┤
│****│****│****│****│***│**│*│
└────┴────┴────┴────┴───┴──┴─┘
2 6 <;. 3 '*'#"0~2 6 7 4 1 7
┌──────┬──────┬─────┬────┬───┬──┬─┐
│** │* │ │ │ │ │ │
│******│***** │**** │*** │** │* │ │
├──────┼──────┼─────┼────┼───┼──┼─┤
│******│***** │**** │*** │** │* │ │
│******│******│*****│****│***│**│*│
├──────┼──────┼─────┼────┼───┼──┼─┤
│******│******│*****│****│***│**│*│
│**** │*** │** │* │ │ │ │
├──────┼──────┼─────┼────┼───┼──┼─┤
│**** │*** │** │* │ │ │ │
│* │ │ │ │ │ │ │
├──────┼──────┼─────┼────┼───┼──┼─┤
│* │ │ │ │ │ │ │
│******│******│*****│****│***│**│*│
├──────┼──────┼─────┼────┼───┼──┼─┤
│******│******│*****│****│***│**│*│
└──────┴──────┴─────┴────┴───┴──┴─┘
Each box can be checked for only having *'s. You would need a way of working
through the shape combinations using something like
{ (i.6);i.7
┌───┬───┬───┬───┬───┬───┬───┐
│0 0│0 1│0 2│0 3│0 4│0 5│0 6│
├───┼───┼───┼───┼───┼───┼───┤
│1 0│1 1│1 2│1 3│1 4│1 5│1 6│
├───┼───┼───┼───┼───┼───┼───┤
│2 0│2 1│2 2│2 3│2 4│2 5│2 6│
├───┼───┼───┼───┼───┼───┼───┤
│3 0│3 1│3 2│3 3│3 4│3 5│3 6│
├───┼───┼───┼───┼───┼───┼───┤
│4 0│4 1│4 2│4 3│4 4│4 5│4 6│
├───┼───┼───┼───┼───┼───┼───┤
│5 0│5 1│5 2│5 3│5 4│5 5│5 6│
└───┴───┴───┴───┴───┴───┴───┘
and then take the maximum dimension of the boxes with only * in the results.
Just a sketch, as I currently don't have time to complete the process and I
think you were looking for approaches rather than complete solutions.
Cheers, bob
ps. 42 is always the answer as long as you choose the right question.
> On Jun 20, 2017, at 8: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