I don't know about the time for {.a,  but this modification helps a bit

earlier on in the brute force process:

   all=: {{ A#~x=".@>A=.   ~.   ,arith^:5 ":each y}}

Putting in a few diagnostics,  I found in one run:

   task ''

terms: 4 7 7 8 9 10
target: 315
┌─────┬──────┬──────┐
│size │934358│339567│
└─────┴──────┴──────┘
#solutions: 428
for example: ((7+(4+7))*(8+10))-9

... where size reports the dimension of A before and after taking its nub,  ~.

I'm afraid I didn't time that one,  but taking the nub appears to have saved

600 000 odd calculations out of 900 000 odd,  as well as 600 000 odd lines/boxes

of calculands.

Cheers,

Mike


On 09/10/2022 18:14, Raul Miller wrote:
https://rosettacode.org/wiki/Countdown#J

    task''
terms: 4 7 8 9 10 10
target: 300
#solutions: 1213
for example: (10+(9*10))*((4+7)-8)

The #solutions line takes approaching 20 seconds. That's not the problem here.

The 'for example' line takes several seconds in J903 (and J904). And
the expression is
    echo 'for example: ',;{.a

The only thing I can think of is that this time is occupied by garbage
collection.

FYI,

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to