Search

๊น€ํฌ์ •

2.๋ฌธ์ œ์ด๋ฆ„
3. ์ˆ˜ํ–‰์‹œ๊ฐ„[์ดˆ(s)]
878
์ข‹์•„์š” ๋ˆ„๋ฅด๊ธฐ
์ข‹์•„์š” ์ˆ˜
: 0
5 more properties
| ์ฝ”๋“œ ์ž‘์„ฑํ•˜๊ธฐ
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๋ฐฐ์—ด ์™„์ „ ํƒ์ƒ‰