from itertools import permutations N = 6 def cycle(p, i): cycled = [(x - p[i]) % (len(p) + 1) for x in p] + [(-p[i]) % len(p) + 1] return tuple(cycled[i+1:] + cycled[:i]) def reversify(p): return tuple(reversed(p)) def find_symmetries(n): symmetries = set() for p in permutations(range(1,n)): pile = {p, reversify(p)} for i in range(len(p)): pile.add(cycle(p, i)) pile.add(cycle(reversify(p),i)) symmetries.add(min(pile)) return symmetries for symmetry in find_symmetries(N): print ((0,) + symmetry)
Standard input is empty
(0, 1, 2, 5, 4, 3) (0, 1, 2, 4, 5, 3) (0, 1, 5, 2, 4, 3) (0, 2, 4, 1, 5, 3) (0, 1, 2, 5, 3, 4) (0, 1, 2, 3, 5, 4) (0, 1, 5, 3, 4, 2) (0, 1, 2, 3, 4, 5) (0, 1, 3, 5, 4, 2) (0, 1, 3, 5, 2, 4) (0, 1, 4, 2, 5, 3) (0, 1, 4, 5, 2, 3) (0, 1, 4, 3, 5, 2) (0, 1, 3, 2, 5, 4)