Skip to content

Commit f74f4e7

Browse files
committed
1 parent c38438b commit f74f4e7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Hongjoo/lv1/모의고사.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
num1 = [1,2,3,...n ] * len(answers) 반복
3+
num2 = [2, 1, 2, 3, 2, 4, 2, 5] 반복
4+
num3 = [3,3,1,1,2,2,4,4,5,5 반복
5+
6+
idea : 답 point = 문제 번호 % 패턴 개수
7+
8+
"""
9+
def solution(answers):
10+
answer = [0] *3
11+
num1 = [1,2,3,4,5]
12+
num2 = [2, 1, 2, 3, 2, 4, 2, 5]
13+
num3 = [3,3,1,1,2,2,4,4,5,5]
14+
# 0. 패턴 정의하기
15+
patterns = [num1, num2, num3]
16+
# 1.정답 개수 세기
17+
for i in range(len(answers)):
18+
for j in range(3):
19+
pattern = patterns[j]
20+
p= i % len(pattern) # point이용
21+
if pattern[p] == answers[i]:
22+
answer[j]+=1
23+
24+
#2. 가장 많이 맞춘 사람(중복 고려)
25+
max_idx = []
26+
max_num = max(answer) #2-1 가장 많이(max) 맞춘 개수 찾기
27+
for i in range(len(answer)) : # 2-2. 3명 돌면서 max 중복 값 가진 사람 idx 색출 -> 추가
28+
if max_num == answer[i] :
29+
max_idx.append(i+1)
30+
print(max_idx)
31+
32+
33+
return max_idx

0 commit comments

Comments
 (0)