방금그곡 - 프로그래머스
def solution(m, musicinfos):
m = m.replace("C#",'H').replace("D#", 'I').replace("F#", 'J').replace("G#",'K').replace("A#",'L')
ret = []
for info in musicinfos:
s, e, name, sheet = info.split(',')
sheet = sheet.replace("C#",'H').replace("D#", 'I').replace("F#", 'J').replace("G#",'K').replace("A#",'L')
sh, sm = map(int, s.split(':'))
eh, em = map(int, e.split(':'))
time = (eh - sh) * 60 + em - sm
while len(sheet) < time:
sheet += sheet
if m in sheet[:time]:
ret.append([name, time, sh])
if not ret:
return "(None)"
ret.sort(key = lambda x: (x[1], -x[2]))
return ret.pop()[0]
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
[Programmers] 쿼드압축 후 개수 세기 - 월간 코드 챌린지1 (python) (0) | 2020.10.14 |
---|---|
[Programmers] 3진법 뒤집기 - 월간 코드 챌린지1 (python) (0) | 2020.10.14 |
프로그래머스 SQL 고득점 Kit 풀이 (0) | 2020.09.26 |
[Programmers] 풍선 터뜨리기 - 월간 코드 챌린지1 (python) (0) | 2020.09.23 |
[Programmers] 삼각 달팽이 - 월간 코드 챌린지1 (python) (0) | 2020.09.16 |