프로그래머스(파이썬)
모음 제거 → in연산자 이용하기
def solution(my_string): answer = '' for x in my_string: if x in [ "a", "e", "i", "o", "u"]: continue else: answer+=x return answer

피로도 - for문 안에 재귀함수가 있는 경우★★+ return값 없음★
일단 아래 코드에서 "순열" 부터 먼저 짚고 가자! arr = [] #순회대상이 되는 리스트 visited=[] #방문흔적을 기록할 체크리스트 result=[] #현재 순열을 담을 리스트 answer=[] #모든 순열을 담을 answer리스트 def dfs(L,r): if L == r: # answer.append(result) //틀림 answer.append(result[:]) return #리턴문이 있어도 되고, 없어도 된다. 재귀함수의 경우 조건이 만족되면, 호출된 스택은 종료된다. else: for i in range(len(arr)): if visited[i] == 0: result[L] = arr[i] visited[i] =1 dfs(L + 1,r) visited[i] = 0 def solu..
주차요금계산 카카오→split(), 1차원 리스트 여러 개 변수로 받기
import math def convert(time): hh, mm = time.split(':') return int(hh)*60 + int(mm) def solution(fees, records): intime = {} result = {} for x in records: time, carNum, inout=x.split() if inout=="IN": #입고 시간 intime[carNum]=convert(time) if carNum not in result: result[carNum]=0 #inout이 "OUT"인 경우 else: #출차시간 #입고시간 result[carNum]+=convert(time)-intime[carNum] del intime[carNum] for key, val in int..
[3차] 압축 → 전진 + 후진, 슬라이싱 "첫자리" 갱신
def solution(msg): answer = [] tmp = {chr(e + 64): e for e in range(1, 27)} num = 27 while msg: # print(msg) tt = 1 # print(tt) #tmp가 포함하고 있는 "문자열"까지 찾기 while msg[:tt] in tmp.keys() and tt