
취미 : 카페 가기
토요일 좋다.
PYTHON
경우의 수 계산
# 테스트 데이터
clothes = [
["yellow_hat", "headgear"],
["blue_sunglasses", "eyewear"],
["green_turban", "headgear"]
]
def solution(clothes):
# 1 : 종류별 의상 갯수를 담는 딕셔너리
clothes_dict = {}
for name, kind in clothes:
if kind in clothes_dict:
clothes_dict[kind] += 1
else:
clothes_dict[kind] = 1
# 1 결과 :
clothes_dict = {
"headgear": 2, # yellow_hat, green_turban
"eyewear": 1 # blue_sunglasses
}
# 2 : 경우의 수 계산
combinations = 1 # 곱셈을 위해 초기값 1 세팅
for count in clothes_dict.values():
combinations *= (count + 1)
# 2 과정 :
headgear의 경우의 수 :
의상 개수 : 2
경우의 수 : 2 + 1 = 3
(yellow_hat, green_turban, 아무것도 입지 않음)
eyewear의 경우의 수 :
의상 개수 : 1
경우의 수 : 1 + 1 = 2
(blue_sunglasses, 아무것도 입지 않음)
# 2 결과 :
루프를 통해 각 종류별 경우의 수를 모두 곱하기 :
첫 번째 반복 :
combinations *= (2 + 1) -> combinations = 1 * 3 = 3
두 번째 반복 :
combinations *= (1 + 1) -> combinations = 3 * 2 = 6
return combinations - 1
# 아무것도 입지 않는 경우의 수 1 빼주기
분류, 회귀, 군집 세션 복습
기초, 심화 강의 복습
기초 1 : ML PYTHON CLASS#1
기초 2 (선형 회귀) : ML PYTHON CLASS#2
기초 3 (로지스틱 회귀) : ML PYTHON CLASS#3
심화 1 (머신러닝 프로세스) : ML PYTHON CLASS#4
오늘의 한 줄.
주말 3일, 평일 4일 하고 싶다 !