def solution(clothes):
clothes_num = {}
for i in clothes:
if i[1] in clothes_num:
clothes_num[i[1]] += 1
else:
clothes_num[i[1]] = 1
cnt = 1
for i in clothes_num.values():
cnt *= i+1
cnt -= 1
return cnt
β· μ΄ λ¬Έμ λ ν€μ κ°μΌλ‘ μ΄λ£¨μ΄μ§ λμ λ리λ₯Ό μ΄μ©νμ¬ ν μ μλ€. μλ₯μ μ’ λ₯λ₯Ό ν€λ‘, ν΄λΉ μ’ λ₯μ ν¬ν¨λ μλ₯λ₯Ό κ°μΌλ‘ λλ€. 첫 λ²μ§Έ for λ¬Έμ μ΄λ₯Ό ꡬννκΈ° μν μ½λμ΄λ€.
β· μ 체 κ²½μ°μ μλ κ° ν΄λΉ μλ₯μ μμ 1μ λν ν, λͺ¨λ κ³±ν λ€, 1μ λΉΌμ€ κ²μ ν΅ν΄ ꡬν μ μλ€.
βΆ λμ λ리λ values ν¨μλ₯Ό μ΄μ©νμ¬ λͺ¨λ ν€μ κ°μ ꡬν μ μλ€. μ΄λ, μΆλ ₯λλ κ°μ 리μ€νΈκ° μλλ―λ‘ μΈλ±μ±μ΄ νμν κ²½μ° list ν¨μλ₯Ό μ΄μ©νμ¬ ννλ₯Ό λ°κΎΈμ΄ μ£Όμ.
'Programming > Coding Test' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Level 2] μ νλ²νΈ λͺ©λ‘ (Python) (0) | 2020.10.05 |
---|---|
[Level 2] H-Index (Python) (0) | 2020.10.05 |
[Level 2] κ΄νΈ λ³ν (Python) (0) | 2020.09.30 |
[Level 2] μΌκ° λ¬ν½μ΄ (Python) (0) | 2020.09.29 |
[Level 2] μΉ΄ν« (Python) (0) | 2020.09.24 |