프로그래머스 LV 1

2024. 1. 28. 13:21백준 및 프로그래머스/프로그래머스 LV 1

-2016년

def solution(a, b):
    answer = ''
    month={1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
    day1 , day2 = 1, 1
    day=["FRI","SAT","SUN","MON","TUE","WED","THU"]
    day_count = 0
    while True:
        if a == day1 and b == day2:
            break
        day2+=1
        if month[day1] < day2:
            day1 +=1
            day2 = 1
        day_count+=1
        
    return day[day_count % 7]

 

-포켓몬

def solution(nums):
    answer = 0
    num = list(set(nums))
    if len(num) >= len(nums) // 2:
        answer = len(nums) // 2
    else:
        answer = len(num)
    return answer

 

-과일장수

def solution(k, m, score):
    answer = 0
    score.sort(reverse=True)
    total = 0
    for i in range(0,len(score),m):
        if i+m > len(score):
            break
        else:
            total+= min(score[i:i+m]) * m 
        
    return total

 

-모의고사

def solution(answers):
    answer = []
    oneperson_math = [1, 2, 3, 4, 5]
    twoperson_math = [2, 1, 2, 3, 2, 4, 2, 5]
    threeperson_math = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
    
    one_count, two_count, three_count =0, 0, 0
    
    for i in range(len(answers)):
        if oneperson_math[i%5] == answers[i]:
            one_count+=1
        if twoperson_math[i%8] == answers[i]:
            two_count+=1
        if threeperson_math[i%10] == answers[i]:
            three_count+=1
    
    if max(one_count,two_count,three_count) == one_count:
        answer.append(1)
    if max(one_count,two_count,three_count) == two_count:
        answer.append(2)
    if max(one_count,two_count,three_count) == three_count:
        answer.append(3)
    
    return answer

'백준 및 프로그래머스 > 프로그래머스 LV 1' 카테고리의 다른 글

숫자 짝꿍 -JAVA  (0) 2025.02.21
프로그래머스 LV1(6)  (0) 2024.01.29
프로그래머스 LV 1(5)  (0) 2024.01.26
프로그래머스 LV1(4)  (0) 2024.01.26
프로그래머스 LV1(3)  (2) 2024.01.26