from collections import Counter
from functools import reduce
def solution(clothes):
answer = 1
cnt = Counter([k for names, k in clothes])
#print(cnt)
#print(cnt.values())
for i in cnt.values():
print(i)
answer *= (i+1)
return answer-1
print(solution([["yellow_hat", "headgear"], ["blue_sunglasses", "eyewear"], ["green_turban", "headgear"]]))
cnt = Counter([k for names, k in clothes])
이거는 clothes라는 배열에
yellow hat같은 첫번째 원소의 애들을 name으로 받고
headgear 같은 두번째 원소의 애들을 clothes..? 모르겠당...
print cnt를 해주면
Counter({'headgear': 2, 'eyewear': 1})으로 뒷원소로 분류돼서 나오고,
cnt.values()을 해주면 dict으로 2랑 1이 순서대로 들어가있다.
2에 1을 더해주고 1에 1을 더해준 값을 같이 곱해주면 총 경우의 수가 나온다.
즉 그 값은 6이 된다. 그치만 옷을 안 입는 경우 1번을 빼줘야해서 answer-1을 한다.