Here's another perspective on your solution: +/\"1(|.\) 1,2&^i.<: 5 1 1 1 1 1 1 2 2 2 2 2 3 4 4 4 4 6 7 8 8 8 12 14 15 16 i=: 13 :'+/\"1(|.\) 1,2&^i.<: y' i [: +/\"1 [: |.\ 1 , [: 2&^ [: i. <:
Linda -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of R.E. Boss Sent: Wednesday, December 10, 2014 12:30 PM To: [email protected] Subject: Re: [Jprogramming] more elegant solution? Can further be simplified to the faster and leaner +/\"1@(|.\)@(1,2&^@i.@<:) 5 1 1 1 1 1 1 2 2 2 2 2 3 4 4 4 4 6 7 8 8 8 12 14 15 16 Some figures 10 ts'(((+ +/),]),:^:(1=#@$))/&.|. <:/~i.1000' NB. REB 3.5132891 27291264 10 ts'(#.@}: + {:)\"1&.|: <:/~i.1000' NB. HR 4.1630193 17839744 10 ts'(+/ . *~ |.@(]\.)@(1 ,~ 2&^)@i.@-.@#) <:/~i.1000' NB. HR 0.59133937 23368960 10 ts'+/\"1@(]\.&.|.@(1,2&^@i.@<:)) 1000' NB. AG 0.012311738 22311040 10 ts'+/\"1@|.\@(1,2&^@i.@<:) 1000' NB. REB 0.0066505051 13913344 R.E. Boss (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics ) > -----Original Message----- > From: [email protected] [mailto:programming- > [email protected]] On Behalf Of Aai > Sent: woensdag 10 december 2014 9:02 > To: [email protected] > Subject: Re: [Jprogramming] more elegant solution? > > Another fast one > > +/\"1@(]\.&.|.@(1,2&^@i.@<:)) n > > > Henry Rich schreef op 09-12-14 om 23:25: > > Same idea, but a pretty efficient implementation: > > > > (+/ . *~ |.@(]\.)@(1 ,~ 2&^)@i.@-.@#) a > > 1 1 1 1 1 > > 1 2 2 2 2 > > 2 3 4 4 4 > > 4 6 7 8 8 > > 8 12 14 15 16 > > > > Henry Rich > > > > On 12/9/2014 8:44 AM, R.E. Boss wrote: > >> Thinking out of my box. > >> Clever interpretation of the pattern. > >> > >> > >> R.E. Boss > >> > >> > >>> -----Original Message----- > >>> From: [email protected] > [mailto:programming- > >>> [email protected]] On Behalf Of Henry Rich > >>> Sent: dinsdag 9 december 2014 13:50 > >>> To: [email protected] > >>> Subject: Re: [Jprogramming] more elegant solution? > >>> > >>> a =. <:/~i.5 > >>> (#.@}: + {:)\"1&.|: a > >>> 1 1 1 1 1 > >>> 1 2 2 2 2 > >>> 2 3 4 4 4 > >>> 4 6 7 8 8 > >>> 8 12 14 15 16 > >>> > >>> Henry Rich > >>> > >>> On 12/9/2014 6:56 AM, R.E. Boss wrote: > >>>> Given the matrix > >>>> <:/~i.5 NB. 5 could be any positive integer > >>>> 1 1 1 1 1 > >>>> 0 1 1 1 1 > >>>> 0 0 1 1 1 > >>>> 0 0 0 1 1 > >>>> 0 0 0 0 1 > >>>> I want to generate > >>>> 1 1 1 1 1 > >>>> 1 2 2 2 2 > >>>> 2 3 4 4 4 > >>>> 4 6 7 8 8 > >>>> 8 12 14 15 16 > >>>> which one would expect to construct with > >>>> ((+ +/),])/&.|.<:/~i.5 > >>>> but then > >>>> 1 1 1 1 1 6 6 6 6 5 35 35 35 34 34 208 208 207 207 207 1245 1244 > >>>> 1244 > >> 1244 > >>>> 1244 > >>>> > >>>> Of course I can think of all kind of solutions of which > >>>> (3 : ('z=.(1-#y)}.y';'for_k. }.i.#y do. z=.z, (k{y) + +/z > >> end.';'z')) > >>>> <:/~i.5 > >>>> I regard the most satisfactory. > >>>> Does anyone has a more elegant tacit solution then > >>>> (((+ +/),]),:^:(1=#@$))/&.|. <:/~i.5 > >>>> 1 1 1 1 1 > >>>> 1 2 2 2 2 > >>>> 2 3 4 4 4 > >>>> 4 6 7 8 8 > >>>> 8 12 14 15 16 > >>>> > >>>> > >>>> R.E Boss > >>>> > >>>> ---------------------------------------------------------------------- > >>>> For information about J forums see > >>> http://www.jsoftware.com/forums.htm > >>>> > >>> ------------------------------------------------------------------ > >>> ---- For information about J forums see > http://www.jsoftware.com/forums.htm > >> ------------------------------------------------------------------- > >> --- > >> For information about J forums see > http://www.jsoftware.com/forums.htm > >> > > -------------------------------------------------------------------- > > -- > > For information about J forums see > http://www.jsoftware.com/forums.htm > > -- > Met vriendelijke groet, > @@i = Arie Groeneveld > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
