코딩테스트/프로그래머스

위장

카늬 2022. 11. 18. 13:27
from functools import reduce

def solution(clothes):
    answer = 0
    dic = {}
    
    for cloth in clothes:
        if cloth[1] in dic:#딕셔너리에 있으면 갯수 추가
            dic.update({cloth[1]:dic.get(cloth[1])+1})
        else:#딕셔너리에 없으면 추가
            dic[cloth[1]] = 2
    
    
    li = list(dic.values())
    answer = reduce(lambda x, y: x * y, li)-1
    print(answer)

    return answer

'코딩테스트 > 프로그래머스' 카테고리의 다른 글

나머지가 1이 되는 수 찾기  (0) 2022.11.18
기능개발  (0) 2022.11.18
전화번호 목록  (0) 2022.11.18
완주하지 못한 선수  (0) 2022.11.18
올바른 괄호  (0) 2022.11.18