1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| def solution(answers): person1 = [1,2,3,4,5] person2 = [2,1,2,3,2,4,2,5] person3 = [3,3,1,1,2,2,4,4,5,5]
result = [0, 0, 0] winner = []
for index, value in enumerate(answers): if len(answers) > len(person1): person1 += person1 if len(answers) > len(person2): person2 += person2 if len(answers) > len(person3): person3 += person3
if value == person1[index]: result[0] += 1 if value == person2[index]: result[1] += 1 if value == person3[index]: result[2] += 1
for index, value in enumerate(result): if value == max(result): winner.append(index + 1)
return winner
|