-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathsolution.py
40 lines (29 loc) · 814 Bytes
/
solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/python3
import math
import os
import random
import re
import sys
from collections import defaultdict
#
# Complete the 'mostActive' function below.
#
# The function is expected to return a STRING_ARRAY.
# The function accepts STRING_ARRAY customers as parameter.
#
def mostActive(customers):
d = defaultdict(int)
for c in customers:
d[c] += 1
return sorted([c for c, cnt in d.items() if cnt / len(customers) >= 0.05])
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
customers_count = int(input().strip())
customers = []
for _ in range(customers_count):
customers_item = input()
customers.append(customers_item)
result = mostActive(customers)
fptr.write('\n'.join(result))
fptr.write('\n')
fptr.close()