You could replace for_q.i.y ... with

qq=. 0
while. y > q=.qq do.
...
qq=. >:qq

Which takes constant space. However, 1e19 is large enough that I suspect you will run out of time brute-forcing it, so you probably need a change in approach regardless.

(For some reason I thought there was special recognition of for_a.i.b but I guess not.)

On Sat, 2 Dec 2023, 'Viktor Grigorov' via Programming wrote:

Hey,

Excuse the possibly inappropriate title. Many projecteuler.net past the first, 
say, 80 problems are or seem to be hard to brute force, at least the way I want 
to write J code. For .https://projecteuler.net/problem=413 for example, the 
below verb does the job, but 1e19 is a bit too big an input. The 2. root is too 
big an input.

{{w=.0 for_q.i.y 
do.w=.w+(([:(1=#)[:(#~(0=z|]))[:;[:"."1&.>[:([:(((-@i.@#@(#~((32{a.)~:]))@{.){]))[:|.(]\))&.>[:<"1(1&}.)^:(i.z=.#q))q=.":q)end.<:w}}

Is getting such a sentence to run down to inserting all applicable special 
combinations, altering internal parameters (like comparison tolerance) via 
foreigns, making it all explicit, and or something else? The problem here  is 
mostly i.1e9 filling my RAM and swap in a blink. Something like flushing the 
buffer, or consistently outputting would be nice.

Any suggestions or recommendations would be appreciated.


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