-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path베스트앨범.py
More file actions
45 lines (29 loc) · 1.2 KB
/
베스트앨범.py
File metadata and controls
45 lines (29 loc) · 1.2 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class TOP :
def __init__(self):
self.first_id = -1
self.first_plays = -1
self.second_id = -2
self.second_plays = -2
self.result = [self.first_id, self.second_id]
def input(self,id, playTimes):
if playTimes > self.first_plays :
self.first_id = id
self.first_plays = playTimes
elif playTimes > self.econd_plays:
self.second_id = id
self.second_plays = playTimes
self.result = [self.first_id, self.second_id]
def solution(genres, plays):
set_genres = list(set(genres))
answer = []
dict_genres = { genre : TOP() for genre in set_genres}
for i in range(len(genres)):
dict_genres[genres[i]].input(i, plays[i])
print( dict_genres.values())
playtiems_array= sort([top.first_plays for top in dict_genres.values()])
for top in dict_genres.values() :
if top.second_id != -2 :
answer[playtiems_array.index(top.first_plays)] = top.result[0]
else :
answer[playtiems_array.index(top.first_plays)] = top.result[0]
return answer