def solution(m, musicinfos):
def cal_time(a,b):
a, b = list(map(int,a.split(':'))), list(map(int, b.split(':')))
return (b[0] - a[0]) * 60 + (b[1] - a[1])
def change_shap(k):
idx = 0
tmp = ''
while idx < len(k):
if idx+1 < len(k) and k[idx] + k[idx+1] in shap:
tmp += shap[k[idx] + k[idx+1]]
idx += 1
else:
tmp += k[idx]
idx += 1
return tmp
answer = []
for i, music in enumerate(musicinfos):
s, e, title, mus = music.split(',')
time = cal_time(s,e)
shap = {'C#': '1', "D#": '2', 'F#':'3', 'G#':'4', 'A#':'5'}
m = change_shap(m)
t = 0
play = ''
mus = change_shap(mus)
while t < time:
play += mus[t%len(mus)]
t+=1
if m in play:
answer.append([-time,i,title])
if len(answer):
answer.sort(key = lambda x: [x[0], x[1]])
return answer[0][2]
else:
return "(None)"
빡 구현 문제
주의 할 점은 #을 바꾸지 않으면 틀린 답이 나온다.