-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgrammers_Lv2_18.py
More file actions
51 lines (39 loc) · 1.29 KB
/
Programmers_Lv2_18.py
File metadata and controls
51 lines (39 loc) · 1.29 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
46
47
48
49
50
51
def cal_minute(start, end):
start_hour, start_min = list(map(int, start.split(':')))
end_hour, end_min = list(map(int, end.split(':')))
start_sum = (start_hour * 60) + start_min
end_sum = (end_hour * 60) + end_min
return end_sum - start_sum
def trans_note(notes):
before = ['C#', 'D#', 'F#', 'G#', 'A#']
after = ['c', 'd', 'f', 'g', 'a']
for note in before:
if note in notes:
idx = before.index(note)
notes = notes.replace(before[idx], after[idx])
return notes
def solution(m, musicinfos):
answer = []
temp = []
check = {}
m = trans_note(m)
for info in musicinfos:
temp.append(info.split(','))
for item in temp:
time = cal_minute(item[0], item[1])
real_song = trans_note(item[3])
song_len = len(real_song)
song = ''
while time > song_len:
song += real_song
time -= song_len
song += real_song[:time]
if m in song:
check[item[2]] = cal_minute(item[0], item[1])
if len(check) == 0:
return "(None)"
max_time = max(check.values())
for key in check.keys():
if check[key] == max_time:
answer.append(key)
return answer[0]