문제조건에는 E#없는데 이거 처리 안하면 27번테케 틀림..조심할것.
parse_set = {'C#': 'a', 'D#': 'b', 'F#': 'c', 'G#': 'd', 'A#': 'e', 'E#': 'k'}
def parse_scale(music):
parsed = []
for idx in range(len(music)):
if music[idx] == '#':
parsed.append(parse_set[parsed.pop()+music[idx]])
else:
parsed.append(music[idx])
return ''.join(parsed)
def make_time(time):
a, b = time.split(':')
return int(a) * 60 + int(b)
def solution(m, musicinfos):
answer, play_time = '', 0
m = parse_scale(m)
for play in musicinfos:
start, end, title, music = play.split(',')
start, end, music = make_time(start), make_time(end), parse_scale(music)
length, total_length = len(music), end - start
music = music * (total_length // length) + music[:total_length % length]
if play_time < total_length and m in music:
answer = title
play_time = total_length
return answer if answer else '(None)'
'practivceAlgorithm > programmers' 카테고리의 다른 글
[Programmers][Python] KAKAO 2018 N진수 게임 (0) | 2021.11.07 |
---|---|
[Programmers][Python] KAKAO 2018 파일명 정렬 (0) | 2021.11.07 |
[Programmers][Python] KAKAO 2018 압축 (0) | 2021.11.04 |
[Programmers][Python] KAKAO 2018 프렌즈 4블록 (0) | 2021.10.31 |
[Programmers][Python] KAKAO 2018 뉴스클러스터링 (0) | 2021.10.31 |