프로그래머스 문제 풀이 - 해시
문제 확인 🏃
[["yellow_hat", "headgear"], ["blue_sunglasses", "eyewear"], ["green_turban", "headgear"]]
>> 5
힌트.
1. yellow_hat
2. blue_sunglasses
3. green_turban
4. yellow_hat + blue_sunglasses
5. green_turban + blue_sunglasses
[["crow_mask", "face"], ["blue_sunglasses", "face"], ["smoky_makeup", "face"]]
>> 3
힌트.
1. crow_mask
2. blue_sunglasses
3. smoky_makeup
def solution(clothes):
all_clothes = {}
for _, key in clothes:
all_clothes[key] = all_clothes.setdefault(key, 0) + 1
answer = 1
for value in all_clothes.values():
answer *= (value+1)
return answer-1
