The constraints (0,3) must never be adjacent, and (1,2) must never be adjacent 
means you are essentially 
looking for the symmetries of a square. If you consider a square with 4 points, 
labeled 0,1,2,3 like this:
0 -------------- 1
| |
| |
| |
| |
| | 
3 -------------- 2


 the symmetries of the square are all permutations such that 0 and 2 (not 0 and 
3) never touch and 1 and 3 never touch.
There are, of course, 8 symmetries of a square (4 rotations and 4 reflections).
You can get them:

Cyc=: i. |."(0 1) i. NB. cyclic group
Dih=: ( (|. @: (0&{) ) ( (C."(_ 1) ) ,~ ]) ]) @: Cyc NB. dihedral group

Dih 4


0 1 2 3
1 2 3 0
2 3 0 1
3 0 1 2
3 2 1 0
0 3 2 1
1 0 3 2
2 1 0 3

in the above list of permutations (0,2) and (1,3) never touch, as desired.
You initial question had (0,3) and (1,2) not touching. This can be got simply 
by relabeling the points.
     On Monday, May 25, 2020, 08:48:09 PM GMT+9, Brian Schott 
<[email protected]> wrote:  
 
 I want all permutations of  i. 4 for which 0 and 3 cannot be adjacent, nor
can 1 and 2. My idea is to create a as follows to describe my situation.

  ]a =. 0 1 1 0,:i. 4

0 1 1 0

0 1 2 3


Next I created b and rotations on b to list the possibilities I can think
of. So I can think of 6 permutations. Are there more and is there a better
way to generate the real qualifying permutations?
  ]b =. 0 1 3 2 ,:1 0 2 3
0 1 3 2
1 0 2 3
  1|."1 b
1 3 2 0
0 2 3 1
  _1|."1 b
2 0 1 3
3 1 0 2
-- 
(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

Reply via email to