ep=:,~:/      NB. Build even parity
   op=:,[:-.~:/  NB. Build odd parity
   ep 1
1 1
   ep 1 1
1 1 0
   op 1
1 0
   op 1 1
1 1 1
   ep 0
0 0
   op 0
0 1

On Tue, Oct 31, 2017 at 4:12 PM, Raul Miller <[email protected]> wrote:

> I am not sure that if there's a better approach, though obviously we
> could rephrase your approach slightly.
>
> For example:
>
>    nextrow=: [ ~: 3 ~:/\ 0,],0:
>    grow=: , _2&{ nextrow {:
>    paritypattern=: 1 }. [ grow@:]^:([-1:) 0 ,: ]
>
> I hope this helps...
>
> --
> Raul
>
>
> On Tue, Oct 31, 2017 at 5:05 PM, Ivan S <[email protected]> wrote:
> > https://oeis.org/A118141
> >
> > "A parity pattern is a matrix of 0's and 1's with the property that
> every 0 is adjacent to an even number of 1's and every 1 is adjacent to an
> odd number of 1's."
> >
> > As a J exercise, I've defined a verb that creates a parity pattern when
> given its height and the first row.
> >
> >    tripsums=: 3: +/\ (0&, @: ,&0)
> >    nextrow=: 2: | (+ tripsums)
> >    grow=: , _2&{ nextrow {:
> >    addzeros=: ,:~ ~:~
> >    paritypattern=: ([: }. grow@:]^:(<: @: [)) addzeros
> >    4 paritypattern 0 0 1 1
> > 0 0 1 1
> > 0 1 0 0
> > 1 1 0 1
> > 0 1 0 1
> >
> > I would love to see other approaches to this problem.
> >
> > - Ivan
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> 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