2 задача

mail@pastecode.io avatar
unknown
python
3 years ago
401 B
4
Indexable
Never
pairs = {}

while True:
  string = input()
  if string == '0': break
  text = string.split(',')
  authors = text[0].split()
  themes = text[1].split()
  for author in authors:
    for theme in themes:
      pair = (author, theme)
      pairs[pair] = pairs.get(pair, 0) + 1

# print(pairs)
mfreq = max(list(pairs.values()))
for pair in pairs:
  if pairs[pair] == mfreq:
    print(pair)