[Jprogramming] AoC 2016 day 9 - Was Re: [Jbeta] possible memory leak j805
Brian Schott
schott.brian at gmail.com
Sun Dec 11 00:00:15 UTC 2016
[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 <
programming at jsoftware.com> 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
>>
>>
>>
>>
>>
>>
More information about the Programming
mailing list