### 테스트 케이스 21, 30이 틀리네용... 8ㅅ8

dict = {"C#" : "H",
"D#" : "I",
"F#" : "J",
"G#" : "K",
"A#" : "L"}

def chr2time(time) :
return(int(time[:2]) * 60 + int(time[3:]))

def notes2chr(notes):
for key, value in dict.items():
notes = notes.replace(key, value)
return(notes)

def solution(m, musicinfos):
m = notes2chr(m)
minutesstore = []
titles = []
for musicinfo in musicinfos:
temp = musicinfo.split(",")
minutes = chr2time(temp[1]) - chr2time(temp[0])
notes = notes2chr(temp[3])
played = (notes * (minutes // len(notes) + 1))[:minutes]
print(m, played)
if m in played :
titles.append(temp[2])
minutes
store.append(minutes)
print(titles, minutesstore)
if len(titles) > 1 :
f = lambda i : minutes
store
return titles[max(range(len(minutes_store)), key = f)]
elif len(titles) == 1 :
return(titles[0])
else :
return "(None)"

이렇게 했는데 테스트케이스 21,30이 틀리네요,,,

노래 해당되면 가장 긴 노래 뽑도록 했고, 길이 같으면 먼저 입력된 곡 나오는거 맞는거 같은데 뭐가 문제일까요?,,

###### 작성중인 코드―solution.py
``````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
from datetime import datetime

dict = {"C#" : "H",
"D#" : "I",
"F#" : "J",
"G#" : "K",
"A#" : "L"}

def notes2chr(notes):
for key, value in dict.items():
notes = notes.replace(key, value)
return(notes)

def solution(m, musicinfos):
m = notes2chr(m)
minutes_store = []
titles = []
for musicinfo in musicinfos:
temp = musicinfo.split(",")
minutes = int((datetime.strptime(temp[1], "%H:%M") - datetime.strptime(temp[0], "%H:%M")).total_seconds() / 60)
notes = notes2chr(temp[3])
played = (notes * (minutes // len(notes) + 1))[:minutes]
if m in played :
titles.append(temp[2])
minutes_store.append(minutes)
print(minutes_store)
if len(titles) > 1 :
f = lambda i : minutes_store
return titles[max(range(len(minutes_store)), key = f)]
elif len(titles) == 1 :
return(titles[0])
else :
return  "(None)"
``````
• 문제조건중에 있어서 정렬하니 그 두개만 통과하더라고요