-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash3_disguise.py
More file actions
38 lines (26 loc) · 960 Bytes
/
hash3_disguise.py
File metadata and controls
38 lines (26 loc) · 960 Bytes
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
t1 = [['yellow_hat', 'headgear'], ['blue_sunglasses', 'eyewear'], ['green_turban', 'headgear']]
r1 = 5
t2 = [['crow_mask', 'face'], ['blue_sunglasses', 'face'], ['smoky_makeup', 'face']]
r2 = 3
from collections import defaultdict
from itertools import combinations
def solution(clothes):
answer = 1
cloth_dict = defaultdict(list)
for (item_name, item_class) in clothes:
cloth_dict[item_class].append(item_name)
groups = list(cloth_dict.values())
for each_group in groups:
answer *= len(each_group) + 1
return answer-1
'''
if len(order_by_class) == 1:
answer += len(list(combinations(order_by_class[0], 1)))
else:
for each_class in order_by_class:
answer += len(list(combinations(each_class, 1)))
answer += len(order_by_class)
return answer
'''
print(solution(t1)) #5
print(solution(t2)) #3