[Programmers] ๋ชจ์๊ณ ์ฌ
Updated:
๋ชจ์๊ณ ์ฌ
๋ชจ์๊ณ ์ฌ ๋ฅผ ํด๋ฆญํ๋ฉด ๋ฐ๋ก ์ด๋ํ๋ค.
ํ๋ก๊ทธ๋๋จธ์ค ์์ ์ ๊ณตํ๋ ์ฝ๋ฉํ ์คํธ ๊ธฐ์ถ๋ฌธ์ ์ค Level 1 ๋ฌธ์ ๋ ๋ค ํ์ด์ Level 2 ๋ฅผ ํ๊ธฐ ์ ์
์ผ๋จ ๊ธฐ์ด ํผํผ Level 1 ๋ฌธ์ ๋ฅผ ์ ๋ถ ํ๊ณ ๊ฐ๋ ค๊ณ ํ๋ค.
๊ทธ ์ค ์ฒซ ๋ฒ์งธ๋ ์์ ํ์์ ์ฌ์ฉํ๋ ๋ชจ์๊ณ ์ฌ ๋ฌธ์ .
def check_answer(answers, checkList, checkCnt):
for index,value in enumerate(answers):
if checkList[index % len(checkList)] == value:
checkCnt += 1
return checkCnt
def solution(answers):
answer = []
answerCnt = []
one = [1, 2, 3, 4, 5]
two = [2, 1, 2, 3, 2, 4, 2, 5]
three = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
oneCnt = twoCnt = threeCnt = 0
answerCnt.append(check_answer(answers, one, oneCnt))
answerCnt.append(check_answer(answers, two, twoCnt))
answerCnt.append(check_answer(answers, three, threeCnt))
for index, value in enumerate(answerCnt):
if max(answerCnt) == value:
answer.append(index+1)
return answer
Level 2 ๋ฌธ์ ๋ฅผ ํ๊ธฐ ์ ์ ๊ฐ๋ ์ ๋ ํผํผํ ํ๊ณ ์ฝ๋๋ก ๋ฐ๊ฟ ์ ์์ ์์ค์ผ๋ก ์ฌ๋ฆฐ ๋ค์ ๋ค๋ฅธ ์์ฉ๋ฌธ์ ๋ฅผ ํ์ด์ผ ๊ฒ ๋ค.
Leave a comment