I was hoping to say I had a brilliant solution to problem 413, but although I do have a script, p413.ijs, it consists only of the statement of the puzzle. It's one of those many I'll get back to, some day. (There was a short period when I'd solved 100%)
The first hundred or so were, I think, written by one chap, at a time when PCs were not so powerful as now. APL and J were great for brute-force, but still quite elegant, solutions. Not so now! They're still marvellous, but there's (nearly?) always a mathematical approach which will crack the Euler-nut. Good Luck. Mike (Sorry - far too chatty,) Sent from my iPad > On 2 Dec 2023, at 07:07, 'Viktor Grigorov' via Programming > <programm...@jsoftware.com> 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