본문 바로가기

PS

프로그래머스 42578 Python [의상]

from collections import Counter

def solution(clothes):
    # 의상 종류 별 개수 카운트
    category_counts = Counter([category for _, category in clothes])
    
    answer = 1
    for count in category_counts.values():
        answer *= (count + 1)  # 안 입는 경우도 고려하기 위해 +1
    return answer - 1  # 모두 안 입은 경우는 제외