fork download
  1. from itertools import permutations
  2.  
  3. N = 6
  4.  
  5. def cycle(p, i):
  6. cycled = [(x - p[i]) % (len(p) + 1) for x in p] + [(-p[i]) % len(p) + 1]
  7. return tuple(cycled[i+1:] + cycled[:i])
  8.  
  9. def reversify(p):
  10. return tuple(reversed(p))
  11.  
  12. def find_symmetries(n):
  13. symmetries = set()
  14. for p in permutations(range(1,n)):
  15. pile = {p, reversify(p)}
  16. for i in range(len(p)):
  17. pile.add(cycle(p, i))
  18. pile.add(cycle(reversify(p),i))
  19. symmetries.add(min(pile))
  20. return symmetries
  21.  
  22. for symmetry in find_symmetries(N):
  23. print ((0,) + symmetry)
  24.  
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
(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)