Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- def all_relations(n):
- for I in itertools.product((0,1),repeat=n**2):
- yield {(i//n, i%n) for i, b in enumerate(I) if b}
- def is_symmetric(rel):
- return all((k[1], k[0]) in rel for k in rel)
- print(len(list(filter(is_symmetric, all_relations(3)))))
Advertisement