티스토리 뷰

https://programmers.co.kr/learn/courses/30/lessons/83201

 

코딩테스트 연습 - 2주차

[[100,90,98,88,65],[50,45,99,85,77],[47,88,95,80,67],[61,57,100,80,65],[24,90,94,75,65]] "FBABD" [[70,49,90],[68,50,38],[73,31,100]] "CFD"

programmers.co.kr

def grade(score):
    if score >= 90: return 'A'
    elif score >= 80 and score < 90: return 'B'
    elif score >= 70 and score < 80: return 'C'
    elif score >= 50 and score < 70: return 'D'
    return 'F'
    
def solution(scores):
    answer = ''
    length = len(scores)
    for col in range(length):
        score = []
        for row in range(length):
            score.append(scores[row][col])
        
        result = sum(score)
        max_score = max(score)
        min_score = min(score)
        if max_score == scores[col][col] and score.count(max_score) == 1:
            result -= max_score
            result = result / (length-1)
        elif min_score == scores[col][col] and score.count(min_score) == 1:
            result -= min_score
            result = result / (length-1)
        else:
            result = result / length
            
        answer += grade(result)
        
    return answer
공지사항
최근에 올라온 글
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함