https://school.programmers.co.kr/learn/courses/30/lessons/42578
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
https://github.com/stellaluminary/Programmers
GitHub - stellaluminary/Programmers
Contribute to stellaluminary/Programmers development by creating an account on GitHub.
github.com
def solution(clothes):
answer = 1
d = {}
for name, type in clothes:
if type not in d:
d[type] = ['', name]
else:
d[type].append(name)
for i in d:
answer *= len(d[i])
return answer - 1
def solution(clothes):
answer = 1
d = {}
for name, type in clothes:
if type not in d:
d[type] = 2
else:
d[type] += 1
for i in d.values():
answer *= i
return answer - 1
def solution(clothes):
from collections import Counter
from functools import reduce
cnt = Counter([kind for name, kind in clothes])
# Noramlly use like "reduce(function, list or dict)"
# However, we can use with additional initial value
# "reduce(function, list or dict, initial value)"
answer = reduce(lambda x, y: x*(y+1), cnt.values(), 1) - 1
return answer