[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค-Lv1] ๋ชจ์˜๊ณ ์‚ฌ / Python

๐Ÿ“š Problem Solving/Programmers

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๋ชจ์˜๊ณ ์‚ฌ

์ˆ˜ํฌ์ž๋Š” ์ˆ˜ํ•™์„ ํฌ๊ธฐํ•œ ์‚ฌ๋žŒ์˜ ์ค€๋ง์ž…๋‹ˆ๋‹ค. ์ˆ˜ํฌ์ž ์‚ผ์ธ๋ฐฉ์€ ๋ชจ์˜๊ณ ์‚ฌ์— ์ˆ˜ํ•™ ๋ฌธ์ œ๋ฅผ ์ „๋ถ€ ์ฐ์œผ๋ ค ํ•ฉ๋‹ˆ๋‹ค. ์ˆ˜ํฌ์ž๋Š” 1๋ฒˆ ๋ฌธ์ œ๋ถ€ํ„ฐ ๋งˆ์ง€๋ง‰ ๋ฌธ์ œ๊นŒ์ง€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฐ์Šต๋‹ˆ๋‹ค. 1๋ฒˆ ์ˆ˜ํฌ์ž๊ฐ€ ์ฐ๋Š”

programmers.co.kr

import sys

input = sys.stdin.readline
answers = list(map(int, input().split()))


def solution(answers):
    first = [1, 2, 3, 4, 5]
    second = [2, 1, 2, 3, 2, 4, 2, 5]
    third = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
    score = [0, 0, 0]
    for i in range(len(answers)):
        if answers[i] == first[i % 5]:
            score[0] += 1
        if answers[i] == second[i % 8]:
            score[1] += 1
        if answers[i] == third[i % 10]:
            score[2] += 1
    answer = []
    temp = max(score)
    for i in range(len(score)):
        if temp == score[i]:
            answer.append(i + 1)
    return answer


print(solution(answers))

 

ํ•ด์„ค

๊ฐ ์‚ฌ๋žŒ ๋ณ„๋กœ ๋‹ต์„ ๋งžํžŒ ์ˆ˜๋ฅผ 1์”ฉ ์ฆ๊ฐ€์‹œ์ผœ์คฌ๋‹ค.

๋งˆ์ง€๋ง‰์—” ๊ฐ€์žฅ ๋†’์€ ๊ฐ’์˜ ์ธ๋ฑ์Šค๋“ค๋งŒ ์ถ”์ถœํ•ด ๋ฆฌํ„ดํ•ด์คฌ๋‹ค.