Skip to content

Commit 1faac86

Browse files
committed
[PGS] 모의고사 / Level 1 / 14분(힌트)
1 parent 00cfaee commit 1faac86

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
def solution(answers):
2+
answer = []
3+
p1 = [1, 2, 3, 4, 5] # 1번 수포자가 찍는 방식
4+
p2 = [2, 1, 2, 3, 2, 4, 2, 5] # 2번 수포자가 찍는 방식
5+
p3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] # 3번 수포자가 찍는 방식
6+
scores = [0, 0, 0] # 각각 1번, 2번, 3번의 점수를 담은 리스트
7+
8+
for i in range(len(answers)): # 시험 문제의 정답 개수만큼 반복
9+
# 정답인지 판별. 이때 찍는 방식의 크기를 넘어가면 나머지 연산을 이용해 반복할 수 있도록 처리
10+
if p1[i%(len(p1))] == answers[i]:
11+
scores[0] += 1
12+
if p2[i%(len(p2))] == answers[i]:
13+
scores[1] += 1
14+
if p3[i%(len(p3))] == answers[i]:
15+
scores[2] += 1
16+
17+
if scores.count(max(scores)) == 3: # 3명이 동점인 경우
18+
answer = [1,2,3]
19+
elif scores.count(max(scores)) == 2: # 2명이 동점인 경우
20+
# 최고점 한 사람 찾은 후, 그 사람의 점수를 0점으로 바꾸고, 다시 최고점을 찾는다.
21+
answer.append(scores.index(max(scores))+1)
22+
scores[scores.index(max(scores))] = 0
23+
answer.append(scores.index(max(scores))+1)
24+
else: # 최고점이 1명만 있는 경우
25+
answer = [scores.index(max(scores))+1]
26+
27+
return answer

0 commit comments

Comments
 (0)