def solution(answers):
one = [1, 2, 3, 4, 5] * 2000
two = [2, 1, 2, 3, 2, 4, 2, 5] * 1250
three = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] * 1000
result = [0, 0, 0, 0]
for i in range(len(answers)):
if (one[i] == answers[i]):
result[1] += 1
if (two[i] == answers[i]):
result[2] += 1
if (three[i] == answers[i]):
result[3] += 1
m = max(result)
arr = []
for i in range(4):
if (result[i] == m):
arr.append(i)
return arr
def solution(answers):
one = [1, 2, 3, 4, 5]
two = [2, 1, 2, 3, 2, 4, 2, 5]
three = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
result = [0, 0, 0]
arr = []
for idx, answer in enumerate(answers):
if (answer == one[idx%len(one)]):
result[0] += 1
if (answer == two[idx%len(two)]):
result[1] += 1
if (answer == three[idx%len(three)]):
result[2] += 1
for idx, order in enumerate(result):
if (order == max(result)):
arr.append(idx+1)
return arr
삽집한 코드
#1번 수포자
one = []
for i in range(1, n+1):
if (i % 5 == 1):
one.append(1)
elif (i % 5 == 2):
one.append(2)
elif (i % 5 == 3):
one.append(3)
elif (i % 5 == 4):
one.append(4)
elif (i % 5 == 0):
one.append(5)
#2번 수포자
two = []
for i in range(1, n+1):
if (i % 2 != 0):
two.append(2)
else:
two.append(one[int(i/2)-1])
#3번 수포자
three = []
for i in range(1, n+1):
if (i % 5 == 1):
three.append(3)
three.append(3)
elif (i % 5 == 2):
three.append(1)
three.append(1)
elif (i % 5 == 3):
three.append(2)
three.append(2)
elif (i % 5 == 4):
three.append(4)
three.append(4)
elif (i % 5 == 0):
three.append(5)
three.append(5)
three = three[:n]