You're welcome!
The parsing does only use negative indexing though (mainly to easily get
rid of the "turn", as the "toggle" cases don't have an element to get rid
of ...)

Actually, I had errors in the updating functions too before ... What you
see is only the final result :)

2015-12-08 14:38 GMT+01:00 Brian Schott <schott.br...@gmail.com>:

> Jan-Pieter,
>
> Thank you very much for your solution.
> Puzzling through it really helped me.
> I think your approach is really clever and your comments were perfect.
> I had trouble understanding your off, on, an toggle until I realized you
> were updating the whole array each time, because my (incomplete) approach
> had involved using amend and only updating the 'through' cells each time.
> Your approach using both positive and negative indexing with { also were a
> break through for me.
>
> On Mon, Dec 7, 2015 at 4:30 PM, Jan-Pieter Jacobs <
> janpieter.jac...@gmail.com> wrote:
>
> > This is my (entirely tacit) solution to problem of day 6.
> > it works by exploiting a pair of nice J features:
> >
> > - ;: for parsing words and it's inverse to piece it together with spaces.
> > - "on","off" and "toggle" defined for changing the lights
> > - "through" for generating lights corresponding to the given indices.
> > - s5parse splits the lines, adds a pair of parentheses, parses words, and
> > rearranges them so each line is formatted as (x1 y1 through x2 y2)
> > action-verb.
> > - Reverse order, so it uses strict right to left precedence, and join
> into
> > one long phrase.
> >
> > Have fun with the deciphering!
> >
> > --
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to