a conjunction binds its (right) arguments ahead of a verb. it builds for sample
0, 3 RB '(3x3)ABC(2x3)XY(5x2)PQRST',1, 9 RB '(3x2)TWO(5x7)SEVEN',0 and then I run this string with ". If it were a verb, I'd need parens around the verb arguments. ----- Original Message ----- From: Brian Schott <[email protected]> To: Programming forum <[email protected]> Sent: Saturday, December 10, 2016 7:00 PM Subject: Re: [Jprogramming] AoC 2016 day 9 - Was Re: [Jbeta] possible memory leak j805 [Mike, Sorry to break into your thread, but the Subject and some content makes it seem appropriate.] Pascal, I have been viewing you solution at the following link. I am intrigued by your use of the conjunction R (RB also). It looks like you are using the m and n arguments of the conjunction as if you would use x and y for a dyadic verb and do not use any x and y for the conjunction. I am not familiar with using only the m and n, but still doing math with them. So my first question is, am I right, so far? My second question is, why are you using a conjunction and not a verb? I want to know if it's more than just a personal preference, or is a verb processed at the wrong time in J's execution, but a conjunction is more adaptable? Or something like that. http://adventofcode.com/2016/day/9 On Sat, Dec 10, 2016 at 1:19 PM, 'Mike Day' via Programming < [email protected]> wrote: [snip] > > > On 10/12/2016 16:47, 'Pascal Jasmin' via Programming wrote: > >> posted a slightly different solution on wiki, but the original did get >> correct answer, even though it took too long. An assumption that turns out >> to be correct to speed it up is that expanding a "substring" expands within >> the confines of that substring. The assumption is sensible if the input is >> in fact the result of a compression routine. With this assumption, you can >> recurse on just the substring to be expanded without expanding it (major >> slowdown in original code) and then just multiply the result by the number >> of repeated expansions. Very similar to original posted code. both parts 1 >> and 2. >> >> >> p1 =: 4 : 0 >> o =. '' >> while. (# y) > e =. ')' i.~ y do. >> b =. '(' i:~ e {. y >> i =. ". every 'x' cut y{~ b + >:i. <:e -b >> o =. o , ',' , (": b) , ', ' , (": {: i) , (x {:: ' R '; ' RB ') , quote >> ({.i) {. (>:e )}. y >> y =. ({.i) }. (>:e) }. y >> end. >> o , ',' , ": # y >> ) >> R =: 2 : ' m * # n' >> RB =: 2 : ' m * (1 +/@:".@:}.@:p1 n)' >> >> echo +/ ". }. 0 p1 LF -.~ a NB. part1 >> echo +/ ". }. 1 p1 LF -.~ a NB. part2 >> >> >> >> >> >> ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
