뭔가 되게 카카오 스러운 문제이다
따로 출처같은건 공개가 안되어있던데
머릿속으로는 쉬운데 막상 코딩하려하면 은근 헷갈리는?
진짜 생각의 흐름대로 코드썼다
def solution(scores):
answer = ''
n = len(scores)
arr = [[0] * n for _ in range(n)]
for i in range(n):
for j in range(n):
arr[i][j] = scores[j][i]
check = []
print(arr)
for i in range(n):
maxx = -1
minn = 101
max_index = []
min_index = []
for j in range(n):
if arr[i][j] >= maxx:
maxx = arr[i][j]
if arr[i][j] <= minn:
minn = arr[i][j]
for j in range(n):
if arr[i][j] == maxx:
max_index.append(j)
if arr[i][j] == minn:
min_index.append(j)
check.append((max_index,min_index))
print(check)
exclude_list = []
for i in range(n):
temp_list = []
maxx = check[i][0]
minn = check[i][1]
if i in maxx and len(maxx) == 1:
temp_list.append(i)
if i in minn and len(minn) == 1:
temp_list.append(i)
exclude_list.append(temp_list)
print(exclude_list)
for i in range(n):
count = n
temp = 0
for j in range(n):
if j in exclude_list[i]:
count -= 1
else:
temp += arr[i][j]
score = temp / count
if score >= 90:
answer += 'A'
elif score >= 80:
answer += 'B'
elif score >= 70:
answer += 'C'
elif score >= 50:
answer += 'D'
else :
answer += 'F'
print(answer)
return answer