Cute Dog Bopping Head
본문 바로가기
Code IT/Algorithm

[프로그래머스] 위장 (Python)

by 찾 2022. 3. 13.

def solution(clothes):
    dictionary = {}
    for cloth in clothes:
        if cloth[1] not in dictionary.keys():
            dictionary[cloth[1]] = [cloth[0]]
        else:
            dictionary[cloth[1]].append(cloth[0])

    count_dict = []
    for key,value in dictionary.items():
        count_dict.append(len(value)+1)

    result = 1
    for count in count_dict:
        result *= count
    
    return result-1

Counter쓰고 싶었는데....

와인 마셔서 취해서 기억이 안났다

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

 

댓글