[프로그래머스] - 길 찾기 게임 (파이썬)
import sys sys.setrecursionlimit(10**3) class Node: def __init__(self, index, x, y): self.index = index self.x = x self.y = y self.left = None self.right = None class Tree: def __init__(self, index, x, y): self.head = Node(index, x, y) def insert(self, index, x, y): curr = self.head while True: if curr.x > x: if curr.left == None: curr.left = Node(index, x, y) break else: curr = curr.left else: ..
2022. 2. 15.
[프로그래머스] - 방금그곡 (파이썬)
sound = {'A#': '1', 'C#': '2', 'D#': '3', 'F#': '4', 'G#': '5'} def solution(m, musicinfos): answer = '' result = [] m = m.replace('A#', sound['A#']) m = m.replace('C#', sound['C#']) m = m.replace('D#', sound['D#']) m = m.replace('F#', sound['F#']) m = m.replace('G#', sound['G#']) for music in musicinfos: title, time, melody = music_melody(m, music) if m in melody: result.append([title, time]) r..
2022. 2. 6.