Thanks, Brian - I thought I needed to put in a temporary intermediate value to avoid
reversing the first change,  hence the three pairs rather than two.

But the enigma remains, doesn't it:  what stops ']' becoming ')' ? Do rplc and/or
stringreplace only work on a maximum of two pairs of before and after?

Peter Vernigorov's post is useful,   but, again,  avoids the difficulty by using an
alternative function, one which I overlooked,  I admit.

Cheers,

Mike

On 18/12/2020 18:54, Brian Schott wrote:
What about the following?
    (   '()',')('  ) stringreplace|. '1 + (2 * 3) + (4 * (5 + 6))'
((6 + 5) * 4) + (3 * 2) + 1

On Fri, Dec 18, 2020 at 1:21 PM 'Michael Day' via Programming <
programm...@jsoftware.com> wrote:

Unlike in the K forum,  the J-wires have been virtually silent on this
year's Advent of Code...

Anyway,  today's problem,  number 18,  might interest J & APLers as part
1 is ALMOST
plug-it-in to J/APL;  there's just one twist,  so to speak,  namely we
need to reverse an
arithmetic expression,  eg
     1 + (2 * 3) + (4 * (5 + 6))
needs to be evaluated as
     ((6 + 5) * 4) + (3 * 2) + 1

--
(B=) <-----my sig
Brian Schott
----------------------------------------------------------------------
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