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