I am unsure how to write down these questions formally, so here is some python code and the problem in words.
I am looking to find all permutations which subscribe to reflective symmetry. For example, given the permutation group $G$ over e.g. {1,2,3,4,5} then I am looking for e.g. {1,2,3,2,1} or {2,2,2,2,2} - i.e. those permutations which are reflective about the center of the permutation.
In code:
n = 6 # length of set
r = 4 # selection
a = [range(n)]*r
all_layouts = list(product(*a))
To find all symmetric permutations:
symmetric_layout = []
r2 = r//2
for t in all_motor_layouts:
is_symmetric = True
for i in range(r2):
if t[i] != t[r - i - 1]:
is_symmetric = False
break
if is_symmetric:
symmetric_layout.append(t)
Examples of all_layouts:
[(0, 0, 0, 0),
(0, 0, 0, 1),
(0, 0, 0, 2),
(0, 0, 0, 3),
(0, 0, 0, 4),
(0, 0, 0, 5),
(0, 0, 1, 0),
(0, 0, 1, 1),
(0, 0, 1, 2),
(0, 0, 1, 3),...]
Example of symmetric_layout:
[(0, 0, 0, 0),
(0, 1, 1, 0),
(0, 2, 2, 0),
(0, 3, 3, 0),
(0, 4, 4, 0),
(0, 5, 5, 0),
(1, 0, 0, 1),
(1, 1, 1, 1),
(1, 2, 2, 1),...]
Questions:
- How is this problem more formally described? (palindrome permutations?) I.e. to find a sub-group of permutations which subscribe to some particular symmetry?
- How can we find this group without, as above, enumerating all of them and seeing if they subscribe to our desired symmetry?
Thanks