06_customs.py 412 B

1234567891011121314151617
  1. #!/usr/bin/env python3
  2. import sys
  3. from functools import reduce
  4. def parse(f):
  5. cur = []
  6. for line in f:
  7. if line == '\n':
  8. yield cur
  9. cur = []
  10. else:
  11. cur.append(line.rstrip())
  12. yield cur
  13. groups = list(parse(sys.stdin))
  14. print(sum(len(reduce(set.union, map(set, g))) for g in groups))
  15. print(sum(len(reduce(set.intersection, map(set, g))) for g in groups))