Here's another option: convert the two rows into one using base 2, discard the ones that are 0, and check if the remaining ones are 1 2 1... I borrowed the sort in Raul's solution so that they must be in that order, not 2 1 2... .
alternate =: (-: 1 2$~$)@:(0 -.~ #.@|:)@:/:~ Note that we don't have to convert to binary. In this case, we end up with alternate =: (-: (0 1,:1 0)$~#)@:(0 0 -.~ |:)@:/:~ Marshall On Fri, Jul 27, 2012 at 10:39 AM, Brian Schott <[email protected]>wrote: > Another approach? > > alternates =: [: -. 1 e. [: +/ 0 1 |."0 1 ] #"_ 1~ +./ > noAnds =: *./@(-.@(*./)) > check =: noAnds *. alternates > > > > > -- > (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
