Algorithm/Programmers

[프로그래머스] 위장 - Python

Dev.sohee 2020. 7. 12. 20:42

https://programmers.co.kr/learn/courses/30/lessons/42578

 

코딩테스트 연습 - 위장

 

programmers.co.kr

def solution(clothes):
    answer = 1
    clothe = {}
    
    for i in range(len(clothes)):
        if clothes[i][1] not in clothe:
            clothe[clothes[i][1]] = 1
        else:
            tmp = clothe[clothes[i][1]]
            tmp += 1
            clothe[clothes[i][1]] = tmp
            
    for c in clothe:
        answer *= (clothe[c] + 1)
        
    answer -= 1
    
    return answer