|
์ฝ๋ ์์ฑํ๊ธฐ
def solution(answers):
answer1 = [1, 2, 3, 4, 5]
answer2 = [2, 1, 2, 3, 2, 4, 2, 5]
answer3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
score = [0,0,0]
for i in range(len(answers)):
if answer1[i%len(answer1)] == answers[i]:
score[0] += 1
if answer2[i%len(answer2)] == answers[i]:
score[1] += 1
if answer3[i%len(answer3)] == answers[i]:
score[2] += 1
arr_answer = []
max_value = max(score)
for i in range(3):
if max_value == score[i]:
arr_answer.append(i+1)
return arr_answer
Python
๋ณต์ฌ
|
์ฝ๋ ์ค๋ช
ํ๊ธฐ
โข
์ ๋ต ๋ฐฐ์ด ์์ ํ์ํ๋ฉด์ ์ํฌ์ 3๋ช
๊ณผ์ ๋ต ๋น๊ต >> score ๊ณ์ฐ
โฆ
๊ฐ๊ฐ ์ํฌ์ ์ ๋ต ํจํด ๋ฏธ๋ฆฌ ์ ์ธ >> i%len(answer1) ๋ฑ์ผ๋ก ํจํด ๋ฐ๋ณต
โข
score ๋ด ์ต๋๊ฐ์ธ ์ธ๋ฑ์ค ๋ฆฌํด
โฆ
์ต๋๊ฐ์ด ์ฌ๋ฌ๊ฐ ์ผ ๊ฒฝ์ฐ๋ฅผ ์ํด score๋ฐฐ์ด ์์ ํ์