alternate=: 0 1 *./@e.~ , , +/,-&(+/\)/&(\:~)

In other words, we are requiring that the following only gives us 1s and 0s:

[a] The starting data
[b] The sums of the two rows
[c] The difference of the running sums of these two rows (rearranging
the rows so that the leftmost 1 appears in the first row)

Note that I have assumed that you are only giving me two rows.  I
should probably also have assumed that you are giving me binary values
(which would let me eliminate the leftmost two commas).

-- 
Raul

On Fri, Jul 27, 2012 at 9:55 AM, David Vaughan <[email protected]> wrote:
> I have an array of shape (2 n), and I want to determine if it has a kind of 
> alternating pattern, where 1s must appear on alternate rows, when reading 
> from left to right.
>
> Some examples that do 'alternate':
>
> 1 0 0 1 0 1
> 0 1 0 0 1 0
>
> 0 1 0 1 0
> 1 0 1 0 1
>
> 0 0 1 0 0 0 0 1
> 1 0 0 0 1 0 0 0
>
> Some examples that do not 'alternate':
>
> 1 0 0 0 1
> 0 1 1 0 0
>
> 1 0 0 1 0 1 1
> 0 1 0 0 1 0 0
>
> 0 1 0 0 1 0
> 1 0 1 1 0 0
>
>
> How can I recognise these cases?
>
> Thanks.
> ----------------------------------------------------------------------
> 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