L2 : 위장 Python

jhyunn·2023년 1월 15일
0

Programmers

목록 보기
25/69

L2 : 위장 Python

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

import numpy as np

def solution(clothes):
    clothes = np.array(clothes)
    answer = 1
    for c in set(clothes[:, 1]):
        answer *= len(clothes[clothes[:, 1]==c])+1
    return answer-1

옷이 선택되지 않을 경우를 감안하여 각 종류 별로 +1을 한 뒤 진행한다.
마지막에 1을 뺀 이유는 모든 옷이 선택되지 않았을 경우를 뜻한다.

profile
https://github.com/Sungjeonghyun

0개의 댓글