From bdee83159af500460e96b3062526401f6aa4a72d Mon Sep 17 00:00:00 2001 From: pigmal24 Date: Sat, 31 Aug 2024 21:15:58 +0900 Subject: [PATCH] =?UTF-8?q?=EC=97=AC=EB=9F=AC=EB=B6=84=20=ED=95=B4?= =?UTF-8?q?=EC=8B=9C=EB=8A=94=20=EB=AD=98=EA=B9=8C=EC=9A=94=3F..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YWCHOI/11to20/12.py | 41 ++++++++++++++++++++++++++++++++++++++++- YWCHOI/11to20/13.py | 22 ++++++++++++++++++++++ YWCHOI/11to20/14.py | 12 ++++++++++++ YWCHOI/11to20/15.py | 13 +++++++++++++ YWCHOI/11to20/16.py | 27 +++++++++++++++++++++++++++ YWCHOI/11to20/17.py | 0 YWCHOI/11to20/18.py | 0 YWCHOI/11to20/19.py | 0 YWCHOI/11to20/20.py | 0 9 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 YWCHOI/11to20/13.py create mode 100644 YWCHOI/11to20/14.py create mode 100644 YWCHOI/11to20/15.py create mode 100644 YWCHOI/11to20/16.py create mode 100644 YWCHOI/11to20/17.py create mode 100644 YWCHOI/11to20/18.py create mode 100644 YWCHOI/11to20/19.py create mode 100644 YWCHOI/11to20/20.py diff --git a/YWCHOI/11to20/12.py b/YWCHOI/11to20/12.py index 3035e8e..0521e04 100644 --- a/YWCHOI/11to20/12.py +++ b/YWCHOI/11to20/12.py @@ -1 +1,40 @@ -print("10에 계속 modified 표시 뜨는데 좀 무섭네요..") \ No newline at end of file +# print("10에 계속 modified 표시 뜨는데 좀 무섭네요..") #test push +# p.153 + +''' +def solution(prices): + stock_length = len(prices) + result_list = [] + + for i in range(prices): + for j in range(i, stock_length): + if i > prices[j]: + result_list[i] = j + continue + + return result_list + + +prices = [1, 2, 3, 2, 3] +print(solution(prices)) +''' + +def solution(prices): + stock_length = len(prices) + result_list = [] + + for i in range(stock_length - 1): + count = 0 + for j in range(i + 1, stock_length): + count += 1 + if prices[i] > prices[j]: + break + result_list.append(count) + + result_list.append(0) + + return result_list + + +prices = [1, 2, 3, 2, 3] +print(solution(prices)) \ No newline at end of file diff --git a/YWCHOI/11to20/13.py b/YWCHOI/11to20/13.py new file mode 100644 index 0000000..6404c8d --- /dev/null +++ b/YWCHOI/11to20/13.py @@ -0,0 +1,22 @@ +def solution(board, moves): + popped_shape_cnt = 0 + moved_shape = 0 + start_list = [[] for _ in range(len(board[0]))] + end_list = [] + + for i in range(len(board) - 1, -1, -1): + for j in range(len(board[0])): + if board[i][j]: + start_list[j].append(board[i][j]) + + for k in moves: + if start_list[k - 1]: + moved_shape = start_list[k - 1].pop() + + if end_list and end_list[-1] == moved_shape: + end_list.pop() + popped_shape_cnt += 2 + else: + end_list.append(moved_shape) + + return popped_shape_cnt \ No newline at end of file diff --git a/YWCHOI/11to20/14.py b/YWCHOI/11to20/14.py new file mode 100644 index 0000000..ef7914e --- /dev/null +++ b/YWCHOI/11to20/14.py @@ -0,0 +1,12 @@ +# 수정해야 함 + +def solution(n, k, cmd): + result_str = "O" * n + + + for command in cmd: + if command.startwith("Z"): + break + + + return result_str \ No newline at end of file diff --git a/YWCHOI/11to20/15.py b/YWCHOI/11to20/15.py new file mode 100644 index 0000000..f9e4292 --- /dev/null +++ b/YWCHOI/11to20/15.py @@ -0,0 +1,13 @@ +from collections import deque + +def solution(N, K): + dq = deque(range(1, N + 1)) # 덱으로 1 ~ N + 1까지 번호매겨 deque에 추가 + + while len(dq) > 1: # 최후의 번호가 남을 때까지 반복 + for i in range(K - 1): # k 번째가 가장 앞으로 오도록 + dq.append(dq.popleft()) # 위 주석 내용에 포함되는 라인 + dq.popleft() # k번째 요소 삭제 + + return dq[0] # 마지막 요소 return + +print(solution(5, 2)) \ No newline at end of file diff --git a/YWCHOI/11to20/16.py b/YWCHOI/11to20/16.py new file mode 100644 index 0000000..2f395db --- /dev/null +++ b/YWCHOI/11to20/16.py @@ -0,0 +1,27 @@ +from collections import deque + +def solution(progresses, speeds): + released_f = [] + day = 0 + count = 0 + + while progresses: + if progresses[0] + day * speeds[0] >= 100: + progresses.pop(0) + speeds.pop(0) + count += 1 + + if not progresses or progresses[0] + day * speeds[0] < 100: + released_f.append(count) + count = 0 + + else: + time +=1 + + return released_f + + + +progresses = [93, 30, 55] +speeds = [1, 30, 5] +print(solution(progresses, speeds)) \ No newline at end of file diff --git a/YWCHOI/11to20/17.py b/YWCHOI/11to20/17.py new file mode 100644 index 0000000..e69de29 diff --git a/YWCHOI/11to20/18.py b/YWCHOI/11to20/18.py new file mode 100644 index 0000000..e69de29 diff --git a/YWCHOI/11to20/19.py b/YWCHOI/11to20/19.py new file mode 100644 index 0000000..e69de29 diff --git a/YWCHOI/11to20/20.py b/YWCHOI/11to20/20.py new file mode 100644 index 0000000..e69de29