Having at last had a go at solving this,  post breakfast (if not Brexit).
I don't think it's a new approach,  but it's fairly nifty.

It considers run lengths times heights.

   a =: >./^:2@:(>:@i.@# ([ * <./\) ])
   qq=:1000?.1000000

   a qq

7030779


   ts'a qq'      NB. time & space
0.0328879 2.24246e7

   ts'maxsqr qq'
0.0385574 322944

So - marginally faster,  but rather space intensive.

Probably better with a stopping condition,  perhaps using ^:_ , rather than
doing all possible heights, but the code would be a bit more complicated, I think.

Cheers,

Mike



On 21/06/2017 14:12, Raul Miller wrote:
    nsqr=: [ * maxbitlen@ceilpos"0 1~
    maxsqr=: >./@(nsqr ~.)



---
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

Reply via email to