You could implement this latter idea something like this:
ok0;ok1=. 1|.ok0=. 1 0 ,: 0 1
+---+---+
|1 0|0 1|
|0 1|1 0|
+---+---+
(ok0;ok1) ([: *./ [: }: [: {. [: > [: +.&.>/ [ E.~&.>~ [: < 0 0 -.&.|:~ ]) C
0
]Cok=:2 5 $ 1 0 0 1 0 0 1 0 0 1
1 0 0 1 0
0 1 0 0 1
(ok0;ok1) ([: *./ [: }: [: {. [: > [: +.&.>/ [ E.~&.>~ [: < 0 0
-.&.|:~ ]) Cok
1
On Mon, Jul 30, 2012 at 4:12 PM, Peter B. Kessler
<[email protected]> wrote:
...
> This doesn't address the case where both inputs have 1's in the same column
>
> ]C=:2 5 $ 1 0 0 1 0 0 1 0 1 0
>
> 1 0 0 1 0
> 0 1 0 1 0
> (>./-<./)+/\+/1 _1 *C
> 1
>
> The original statement of the problem doesn't say what to do with
> simultaneous 1's, but I would think they fail the "alternating" description.
>
...
> Conversely, why is it not J-like to filter out the 0 0 columns (and check
> for 1 1 columns while you are there), then match successive 2x2 blocks to
> make sure they are all the same? Either "2 2 $ 0 1 1 0" or "2 2 $ 1 0 0 1",
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm