Thanks, Rob.

I suppose one gets to expect more than one parts to these problems with one or two under one's belt. Pascal Jasmin has apparently posted code somewhere on an associated website, but I haven't found it,
so here's my code, fwiw.

I've copied to notepad and back,  but I expect the comments will wrap.

unpack2=: 3 : 0
0 unpack2 y                  NB. default to non-recursive (part one) problem
:
comptxt =. y                 NB. compressed text
decomplg=. 0                 NB. decompressed text counter
while. (#comptxt) > >./ ixb =. comptxt i. '()' do. NB. while some markers remain 'ixob ixeb' =. ixb NB. indices of next brackets 'lg mult' =. 'x'(".;._2@,~) (ixob+1) }. ixeb {. comptxt NB. marker ==> length, multiplier need =. >: ixeb + lg NB. actual amount of text to take/drop
   if. x do. lg =. 1 unpack2 (1+ixeb) }. need{. comptxt end.
decomplg =. decomplg + ixob + lg * mult NB. increment decompressed text counter
   comptxt     =. need }.  comptxt
end.
decomplg + # comptxt         NB. pad remaining uncompressed text
)

Time and space

NB. "problem" is the result of freads on file.
NB. Pascal Jasmin's p1
NB. ts'+/ ". }. 0 p1 LF -.~ problem' NB. part1
NB. 0.00226887 364928
NB. ts'+/ ". }. 1 p1 LF -.~ problem' NB. part2
NB. 0.0700624 650112

NB. Mike's unpack
NB. ts'unpack2 problem' NB. part1
NB. 0.000504854 35456
NB. ts'1 unpack2 problem' NB. part2
NB. 0.0342998 68992

Thanks,

Mike



On 11/12/2016 09:43, Rob Hodgkinson wrote:
Part 2 only becomes visible once you have submitted a correct entry for Part 1.

Upon successful submission, it gives you the option to “Return to Problem n”, 
and re-displays Part 1, along with your “correct” answer, then below that the 
Part 2 extension.

Cheers Mike, Rob

On 11 Dec. 2016, at 7:18 pm, 'Mike Day' via Programming 
<programm...@jsoftware.com> wrote:

Trying the patience of the forum here,  but may I ask: were both parts of the 
problem

visible all the time?   After getting part one correct I started looking for 
and found part

two below part one's submission area - either it was already there,  or else it 
was

revealed by the correct entry.


Anyway, when I did part one,  I had no idea that there was a part two,  hence 
my silly remarks

(in J Beta) about there being no need for recursion.


Thanks,

Mike



On 11/12/2016 04:53, 'Pascal Jasmin' via Programming wrote:
I planned (and used) conjunctions for both parts to take advantage of the 
binding preference of conjunctions.  I'd need fewer parens.

  4 (2 : 'm+n') 3 , 1
7 1
  4 + 3 , 1
7 5

the conjunction executes before ,

It refers to the R or RB in the generated string/code.





----- Original Message -----
From: Brian Schott <schott.br...@gmail.com>
To: Programming forum <programm...@jsoftware.com>
Sent: Saturday, December 10, 2016 11:47 PM
Subject: Re: [Jprogramming] AoC 2016 day 9 - Was Re: [Jbeta] possible memory 
leak j805

Yes, my bad. I was *blind* to the left-most 1 in the expression below.

(1 +/@:".@:}.@:p1 n)

But what about the rest of my questions:

a) When you first did part 1 did you use a conjunction, or was the
conjunction only needed in part 2, and so you revised part 1 to be similar?

b) And you state, "a conjunction binds its (right) arguments ahead of a
verb." Can you be specific about what verb you mean here. Is it the p1 that
is referred to inside of RB or some other verb?

By the way, I have considered putting my solution on the wiki as one NOT to
do because it is so inefficient it takes over 2 hours. You see, I
constructed all of the expanded strings and only counted their length after
all was computed. I think the time may have been exaggerated by all of the
disk swapping that must have been required. So I really was astonished by
the speed of your solution.


Thanks, again.


On Sat, Dec 10, 2016 at 11:29 PM, 'Pascal Jasmin' via Programming <
programm...@jsoftware.com> wrote:

part 1 emits R, part 2 emits RB.  RB parses the string in n argument with
1&p1 (which will emit RBs recursively)

the x argument of p1 determines whether its part 1(R) or part 2(RB) format.






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

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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

Reply via email to