λ¬Έμ λ§ν¬
λ΄κ° μ΄ νμ΄
# λ‘λ λ²νΈ λΉμ²¨ 체ν¬νλ ν¨μ
def isWin(win_nums, lotto):
for num in win_nums:
if (num == lotto):
return True
return False
# λν¬ κ³μ°ν΄μ£Όλ ν¨μ
def getRankByWin(win):
if (win < 2): # 0,1κ°λ λͺ¨λ 6μ (tc ν¬ν¨ν΄μΌ νλ μΌμ΄μ€)
return 6;
else:
return 7 - win; # λν¬ + μμ = 7μ΄λ―λ‘
def solution(lottos, win_nums):
hidden = 0 # μμλ³Ό μ μλ λ²νΈ
win = 0 # λ§μΆ λ²νΈ κ°―μ
for lotto in lottos:
# μμλ³Ό μ μλ λ²νΈμΈ κ²½μ°
if lotto == 0:
hidden += 1
else:
if (isWin(win_nums, lotto)) :
win += 1
# print(win, hidden)
min = getRankByWin(win) # λΉμ²¨ κ°―μλ‘ λνΉ μ‘°ν
max = getRankByWin(win + hidden) # λΉμ²¨ κ°―μλ‘ λνΉ μ‘°ν
return [max, min]
λ€λ₯Έ μ¬λ νμ΄
def solution(lottos, win_nums):
rank=[6,6,5,4,3,2,1]
cnt_0 = lottos.count(0)
ans = 0
for x in win_nums:
if x in lottos:
ans += 1
return rank[cnt_0 + ans],rank[ans]
λ°μν
'π€ μκ³ λ¦¬μ¦' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
baekjoon. λ¬Έμμ΄ νλ° (0) | 2022.08.29 |
---|---|
programmers. λ€λ¨κ³ μΉ«μ ν맀 (0) | 2022.06.29 |
μκ³ λ¦¬μ¦ κΏν. μλ° (0) | 2022.06.27 |
programmers. νλ ¬ ν λ리 νμ νκΈ° (0) | 2022.06.26 |
ν΄μ»€λν¬. Sorting: Bubble Sort (java) (0) | 2022.03.26 |