-
[위클리 챌린지] 2주차알고리즘/프로그래머스 2021. 8. 25. 19:56
https://programmers.co.kr/learn/courses/30/lessons/83201?language=python3
- Python 풀이
# 2차원 리스트 슬라이싱을 쓰려고, numpy사용
import numpy as np def solution(scores): scores = np.array(scores) answer = '' dic = {} for i in range(len(scores)): dic.setdefault(i, list(scores[:,i])) for i in range(len(scores)): if dic[i].count(dic[i][i])==1 and (min(dic[i])==scores[i][i] or max(dic[i])==scores[i][i]): del dic[i][i] for i in range(len(dic)): temp = sum(dic[i])/len(dic[i]) if temp >= 90: answer += 'A' elif temp >= 80: answer += 'B' elif temp >= 70: answer += 'C' elif temp >= 50: answer += 'D' else: answer += 'F' return answer
'알고리즘 > 프로그래머스' 카테고리의 다른 글
[해시] 베스트앨범 (0) 2021.09.04 [위클리 챌린지] 3주차 (0) 2021.08.29 [위클리 챌린지] 4주차 (0) 2021.08.24 [위클리 챌린지] 1주차 (0) 2021.08.24 [2021 KAKAO BLIND RECRUITMENT] 순위 검색 (0) 2021.08.23