공부(143)
-
크레인 인형뽑기 게임 - Python
1. 풀이 코드def solution(board, moves): answer = 0 row = len(board) output_list = [] for index in moves: is_check = True for i in range(row): target = board[i][index - 1] # print(f"-->{target}") if target == 0: continue else: while len(output_list) > 0: pre_target = output_list.pop(..
2025.07.16 -
[PCCE 기출문제] 10번 / 데이터 분석 - Python
1. 풀이 코드def solution(data, ext, val_ext, sort_by): answer = [] type_list = { "code": 0, "date": 1, "maximum": 2, "remain": 3 } sort_idx = type_list[sort_by] data.sort(key=lambda x: x[sort_idx]) filter_idx = type_list[ext] for target in data: if target[filter_idx] 2. 다른 사람 풀이 코드def solution(data, ext, val_ext, sort_by): ans..
2025.07.15 -
햄버거 만들기 - Python
1. 풀이 코드def check_list(target_list:list): is_need_check = False for index in range(len(target_list) - 3): if target_list[index:index+4] == [1, 2, 3, 1]: del target_list[index:index+4] is_need_check = True return is_need_check, target_list return is_need_check, Nonedef solution(ingredient): answer = -1 is_need_check = True while is_need_ch..
2025.07.14 -
[PCCE 기출문제] 9번 / 이웃한 칸 - Python
1. 풀이 코드def solution(board, h, w): answer = 0 up_cell = board[h - 1][w] if h - 1 >= 0 else 'x' down_cell = board[h + 1][w] if len(board) > h + 1 else 'x' left_cell = board[h][w - 1] if w - 1 >= 0 else 'x' right_cell = board[h][w + 1] if len(board) > w + 1 else 'x' for item in [up_cell, down_cell, left_cell, right_cell]: if item == board[h][w]: answer += 1 r..
2024.11.22 -
알고리즘 가이드: 주요 접근 방법 정리
보호되어 있는 글입니다.
2024.11.22 -
체육복 - Python
1. 풀이 코드def solution(n, lost, reserve): answer = 0 student_list = [1 for _ in range(n)] for lost_index in lost: lost_index -= 1 student_list[lost_index] -= 1 for reserve_index in reserve: reserve_index -= 1 student_list[reserve_index] += 1 if student_list[0] == 2 and student_list[1] == 0: student_list[0] = 1 student_list[1] = 1..
2024.11.22 -
30970 선택의 기로 - Python
1. 풀이 코드N = int(input())quality = []quantity = []for _ in range(N): qual, quan = map(int, input().split(' ')) quality.append([qual, quan]) quantity.append([quan, qual])quality.sort(key=lambda x: (-x[0], x[1]))quantity.sort(key=lambda x: (x[0], -x[1]))# print(quality)# print(quantity)print(f"{quality[0][0]} {quality[0][1]} {quality[1][0]} {quality[1][1]}")print(f"{quantity[0][1]} {quanti..
2024.08.06