λ°μν
π€λ¬Έμ ν΄κ²°
- λ§μ κ°μμ 0(쑰컀)λ₯Ό μΉ΄μ΄νΈνλ€.
- μ΅λ = λ§μ κ°μ + 쑰컀
- μ΅μ = λ§μ κ°μ
- κ°μμ λ°λΌ λ±μλ₯Ό λΆμ¬νλ€. ( 0μ΄ μλλ©΄ 7 - (λ§μκ°μ) ν΄μ£Όλ©΄ λ±μ )
π»μμ€ μ½λ
def solution(lottos, win_nums):
answer = []
right = 0 # 보μ΄λκ² μ€ λ§μ κ²
zero_cnt = 0 # 0μ 쑰컀
for lotto in lottos:
if lotto == 0:
zero_cnt += 1
continue
if lotto in win_nums:
right += 1
min_rank = right
max_rank = right + zero_cnt
if max_rank > 0:
answer.append(7-max_rank)
else:
answer.append(6)
if min_rank > 0:
answer.append(7-min_rank)
else:
answer.append(6)
return answer
πλ¬Έμ νμΈ
μΆμ²: νλ‘κ·Έλλ¨Έμ€
λ§ν¬: λ‘λμ μ΅κ³ μμμ μ΅μ μμ
λ°μν
'Algorithm Problem > Python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[python] νλ‘κ·Έλλ¨Έμ€ - μ½μμ κ°μμ λ§μ (0) | 2021.06.21 |
---|---|
[python] νλ‘κ·Έλλ¨Έμ€ - μμ λνκΈ° (0) | 2021.06.20 |
[python] SWEA - 3131. 100λ§ μ΄νμ λͺ¨λ μμ (0) | 2020.12.23 |
[python] SWEA - 3750. Digit sum (0) | 2020.12.22 |
[python] SWEA - 3408. μΈκ°μ§ ν© κ΅¬νκΈ° (0) | 2020.12.21 |