For small sets I'd start with the permutations, then select those I like. This shows two anti-selectors, sum of pairs equal 3, and in r2 the bad guys are directly spelled.
permutations=: A.&i.~ ! Filter=: "1(#~`)(`:6) restrictions=: 1 (-.@e.) 3 = 2&(+/\) NB. 1 where none of the length 2 infix sums equal 3 restrictions Filter permutations 4 0 1 3 2 0 2 3 1 1 0 2 3 1 3 2 0 2 0 1 3 2 3 1 0 3 1 0 2 3 2 0 1 NB. directly enter those I don't want r2=: 1 -.@e. [: , (>0 3;1 2;2 1;3 0)&(E."1) (r2 Filter -: restrictions Filter)@:permutations 4 1 > Am 25.05.20 um 13:47 schrieb Brian Schott: > I want all permutations of i. 4 for which 0 and 3 cannot be adjacent, nor can 1 and 2. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
