Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Counter
- with open("input.txt", "r", encoding="utf-8") as file:
- buys_count = Counter()
- buys = [line.strip().split(",") for line in file.readlines()]
- for buy in buys:
- buys_pairs = []
- buy.sort()
- for i in range(len(buy)):
- for j in range(i, len(buy)):
- if buy[i] != buy[j]:
- buys_pairs.append((buy[i], buy[j]))
- buys_count.update(buys_pairs)
- max_count = buys_count.most_common(1)[0][1]
- max_buy = None
- for buy in buys_count.most_common():
- if buy[1] == max_count:
- if max_buy == None or buy[0] <= max_buy:
- max_buy = buy[0]
- print(",".join(max_buy))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement