본문 바로가기

Python262

[프로그래머스] 옹알이(1) def solution(babbling): answer = 0 available = ('aya','ye','woo','ma') available_prefix = ('a','y','w','m') def checkFunc(arr): arr_length = len(arr) i = 0 while(i 2023. 7. 18.
[프로그래머스] 바탕화면 정리 def solution(wallpaper): left_top = [49,49] right_down = [0,0] row_l, col_l = len(wallpaper), len(wallpaper[0]) area = [[""]*col_l for _ in range(row_l)] for i,row in enumerate(wallpaper): for j,item in enumerate(row): area[i][j] = item if item == "#": left_top[0] = min(left_top[0],i) left_top[1] = min(left_top[1],j) right_down[0] = max(right_down[0],i+1) right_down[1] = max(right_down[1],j+1) r.. 2023. 6. 23.
[프로그래머스] 공원 산책 def solution(park, routes): row_l = len(park) col_l = len(park[0]) start_location = (0,0) route_list = [] area = [[""]*col_l for _ in range(row_l)] for i,row in enumerate(park): for j,item in enumerate(row): area[i][j] = item if item == "S": start_location = [i,j] for i in routes: route_list.append((i[0],int(i[2]))) for i in route_list: d, n = i[0], i[1] exist_x = False if d == "N": if (start_lo.. 2023. 6. 23.
[프로그래머스] 추억점수 def solution(name, yearning, photo): answer = [] # {'may': 5, 'kein': 10, 'kain': 1, 'radi': 3} name_dict = {name:yearning[i] for i,name in enumerate(name)} for i,row in enumerate(photo): total = 0 for j,col in enumerate(row): if name_dict.get(col) != None: total += name_dict[col] answer.append(total) return answer 이번 문제는 사전 자료형을 사용하여 간단하게 풀 수 있던 문제였다. 여기서 기억해야 할 점은 사전 자료형에서 어떠한 값을 접근할 때 get() 메.. 2023. 6. 23.
[프로그래머스] 달리기 경주 def solution(players, callings): # {'mumu': 0, 'soe': 1, 'poe': 2, 'kai': 3, 'mine': 4} player_dict = {player:rank for rank,player in enumerate(players)} # {0: 'mumu', 1: 'soe', 2: 'poe', 3: 'kai', 4: 'mine'} rank_dict = {rank:player for rank,player in enumerate(players)} for call in callings: call_index = player_dict[call] prev_index = call_index -1 player_dict[rank_dict[call_index]], player_di.. 2023. 6. 23.
[Softeer 기출문제] GBC import sys n,m = map(int,input().split()) limit = [0]*101 index = 1 test_index = 1 max_value = 0 for i in range(n): length, limit_fast = map(int,input().split()) for j in range(index,index+length): limit[j] = limit_fast index += length for i in range(m): test_length, test_fast = map(int,input().split()) for j in range(test_index,test_index + test_length): if test_fast > limit[j]: diff = test_fas.. 2023. 5. 30.