목록문제/프로그래머스_파이썬 (13)
sm 기술 블로그
num = [0,3,2,1,0,1,2,3] name = [["R","T"], ["C","F"], ["J","M"], ["A","N"]] score = [[0,0],[0,0],[0,0],[0,0]] def sumScoreA(x, choice): if(choice < 4) : score[x][0] += num[choice] else : score[x][1] += num[choice] def sumScoreB(x, choice): if(choice < 4) : score[x][1] += num[choice] else : score[x][0] += num[choice] def indicator(x, s, choice): if(s == "RT" or s == "CF" or s == "JM" or s == "AN"..
import re def step_1(id): return id.lower() def step_2(id): return re.sub(r'[^0-9a-z-_.]', "", id) def step_3(id): while(id.find("..") != -1): id = id.replace("..",".") return id def step_4(id): if(id[0] == "."): id = id[1:] if(len(id) != 0 and id[-1] == "."): id = id[:len(id)-1] return id def step_5(id): if(len(id)==0): id = "a" return id def step_6(id): if(len(id)>=16): id = id[:15] id = step_..
phone = [[1,2,3], [4,5,6], [7,8,9], ["*",0,"#"]] def findIndex(n): for i in range(len(phone)): for j in range(len(phone[i])): try: return [i, phone[i].index(n)] break except: continue def solution(numbers, hand): left = findIndex("*") right = findIndex("#") current = [] result = [] answer = '' for n in numbers: if n == 1 or n == 4 or n == 7: left = findIndex(n) result.append("L") elif n == 3 or ..
from collections import deque queue = deque() def solution(board, moves): answer = 0 for i in moves: for j in range(len(board[i-1])): if(board[j][i-1] != 0): tmp = board[j][i-1] board[j][i-1] = 0 try: if queue[-1] == tmp : queue.pop() answer+=2 else: queue.append(tmp) except: queue.append(tmp) break return answer 문제요약 인형을 집어 바구니에 쌓아서 넣는다. -> 바구니에 중복으로 인형이 2개 있으면 2개를 없애고 없앤 수를 answer로 한다. 설명 이 문제..