Farmer John has been keeping detailed records of his cows as they enter the barn for milking. Each hour, a group of 3 cows enters the barn, and Farmer John writes down their names. For example over a 5-hour period, he might write down the following list, where each row corresponds to a group entering the barn:
BESSIE ELSIE MATILDA FRAN BESSIE INGRID BESSIE ELSIE MATILDA MATILDA INGRID FRAN ELSIE BESSIE MATILDA
Farmer John notes that the same group of cows may appear several times on his list; in the example above, the group of BESSIE, ELSIE, and MATILDA appears three times (even though Farmer John didn't necessarily write their names in the same order every time they entered the barn).
Please help Farmer John count the number of occurrences of the group entering the barn the most.
key
는 리스트가 될 수 없다. mutable
하기 때문tuple
은 내부 값을 수정/추가 할 수 없기 때문에 immutable
하다.from sys import stdin
from collections import defaultdict
n = int(stdin.readline())
total = defaultdict(int)
for _ in range(n):
lst = tuple(sorted(list(map(str, stdin.readline().split()))))
total[lst] += 1
tmp = sorted(total.items(), key = lambda x : x[1], reverse= True)
print(tmp[0][1])