[Jprogramming] largest rectangle problem
Linda Alvord
lindaalvord at verizon.net
Thu Jun 29 15:27:21 UTC 2017
I hope this is the right thread. A better tacig thanks to Raul.
f=: 13 :'>./ (([: ([: >: i.) #)y)([: >./ [ * <./\)y'
f qq
7030779
f
[: >./ ] ([: >./ [ * <./\)~ [: ([: >: i.) #
Linda
-----Original Message-----
From: Programming [mailto:programming-bounces at forums.jsoftware.com] On Behalf Of 'Mike Day' via Programming
Sent: Wednesday, June 28, 2017 12:40 PM
To: programming at jsoftware.com
Subject: Re: [Jprogramming] largest rectangle problem
Linda, bear in mind that Raul was (I think) deriving a tacit improvement of my explicit verb "c" which had incorporated an explicit loop.
Here it is, again, possibly without gratuitous line-throws:
c =: 3 : 0
m =. >./y
for_i. }.>:i.#y do.
m =. m >. >./ i ([ * <./\) y
end.
)
It happens to include neither @ and @: which you deprecate, nor [: which you prefer.
My later modification, cs, not reproduced here, includes an early stopping condition, which speeds things up, at least for an object like qq.
Raul and others have posted further improvements to cs.
What you wanted?
Cheers,
Mike
On 28/06/2017 14:45, Linda Alvord wrote:
> I turned your verb to a different expression. Can you write my version as an explicit verb?
>
>
> f=: [:>./([:([:>:i.)#)([: >./[ * <./\)"0 1 ]
>
> f qq
> 7030779
>
> Linda
>
> -----Original Message-----
> From: Programming [mailto:programming-bounces at forums.jsoftware.com] On
> Behalf Of Raul Miller
> Sent: Saturday, June 24, 2017 2:38 PM
> To: Programming forum <programming at jsoftware.com>
> Subject: Re: [Jprogramming] largest rectangle problem
>
> Oops, I used <./ instead of >./ when I typed that in.
>
> Should have been:
>
> C=: >./@(>:@i.@# >./@([ * <./\)"0 1 ])
>
> I am not quite sure how I made that mistake - just sloppy, I guess.
>
> Thanks,
>
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list