JoelSjogren

Untitled

Aug 13th, 2020
670
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. import itertools
  2.  
  3. def all_relations(n):
  4. for I in itertools.product((0,1),repeat=n**2):
  5. yield {(i//n, i%n) for i, b in enumerate(I) if b}
  6.  
  7. def is_symmetric(rel):
  8. return all((k[1], k[0]) in rel for k in rel)
  9.  
  10. print(len(list(filter(is_symmetric, all_relations(3)))))
  11.  
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment