목록카카오 (7)
Head vs breakz
def solution(msg): word_list =['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] status = True total = True count = 0 val_count = 0 answer = [] for i in range(len(msg)): for j in range(len(msg),0,-1): if msg[i:j] in word_list and status ==True : answer.append(word_list.index(msg[i:j])+1) word_list.append(msg[i:j+1]) count += j-i if j-i > 1: ..
#튜플 def solution(s): b = [] a = list(s[2:-2].split("},{")) a.sort(key = len) for i in range(len(a)): c=list(a[i].split(",")) for j in range(len(c)): if c[j] not in b : b.append(c[j]) for q in range(len(b)): b[q] = int(b[q]) answer = b return answer 문자열을 쪼개고, 다시 리스트로 쪼개고, 문자가 없으면 넣어주고 문자를 숫자로 변환
#n 진수 게임 def solution(n, t, m, p): numbers = [] answer =[] for i in range(0,t*m): a = numeral_system(i,n) numbers.append(a) numbers_a= list(''.join(numbers)) for j in range(p-1,t*m,m): answer.append(numbers_a[j]) answer=''.join(answer) return answer rotation = '0123456789ABCDEF' def numeral_system(number , base): q, r = divmod(number, base) n = rotation[r] return numeral_system(q, base) + n if q..
# 괄호변환 def solution(p): if p =="": return "" elif len(p) % 2 == 0: qq = div_val(p,point_val(p)) return qq def point_val(p): a = 0 count = 1 q = list(p) for i in range(len(q)): if q[i]=="(": count +=2 if count == 1: a = i break elif q[i]==")": count -=2 if count == 1: a = i break return a def div_val(p,a): count = [] q = list(p) u =q[:a+1] v =p[a+1:] if check_val(u) ==True : return p[:a+1]+soluti..