point
경우의 수, collection.Counter
Counter
함수를 사용했다.import collections
def solution(clothes):
types = [x[1] for x in clothes]
types_num = collections.Counter(types)
clothes_num = 1
for t in types_num.keys():
clothes_num *= types_num[t]+1
answer = clothes_num - 1
return answer
clothes_num *= types_num[t]+1
부분에서 덧셈 부분에 괄호를 넣어주지 않아 계산 결과가 올바르게 나오지 않았다.import collections
def solution(clothes):
types = [x[1] for x in clothes]
types_num = collections.Counter(types)
answer = 1
for t in types_num:
answer *= (types_num[t]+1)
return answer -1
import collections
def solution(clothes):
types = [x[1] for x in clothes]
types_num = collections.Counter(types)
answer = 1
for t in types_num:
answer = answer * (types_num[t] + 1)
return answer -1